Post

How to add project in aspnetcore repo?

I tried to add my project as described in \aspnetcore\docs\ReferenceResolution.md but some of the explanations were not obvious to me, so I made a small guide.

  1. Add project (it is obvious) in dir \src\MyProject. Add a inner dir src as is customary here so eventually path to project will be \src\MyProject\sec.

  2. Add in \eng\Build.props
    1
    2
    3
    4
    5
    6
    7
    
       <DotNetProjects Include="
                               $(RepoRoot)src\MyProject\**\src\*.csproj;
                            ...
                               "
                             Exclude="
                               ..."
                             Condition=" '$(BuildMainlyReferenceProviders)' == 'true' " />
    
  3. Run \eng\scripts\GenerateProjectList.ps1
  4. Add in eng\Dependencies.props

    1
    2
    3
    4
    
     <ItemGroup Label=".NET team dependencies (Non-source-build)" Condition="'$(DotNetBuildFromSource)' != 'true'">
     ...
         <LatestPackageReference Include="MyProject" />
     </ItemGroup>
    
  5. Run \restore.cmd

  6. dotnet sln AspNetCore.sln add .\src\MyProject\src
  7. Now you can add links to any csproj <Reference Include="MyProject" />
  8. Add scripts to \src\MyProject\ to work with project

    • build.cmd
      1
      2
      3
      4
      
        @ECHO OFF
        SET RepoRoot=%~dp0..\..
      
        %RepoRoot%\eng\build.cmd -projects %~dp0**\*.*proj %*
      
    • MyProject.slnf
      1
      2
      3
      4
      5
      6
      7
      8
      
        {
          "solution": {
            "path": "..\\..\\AspNetCore.sln",
            "projects": [
              "src\\MyProject\\src\\MyProject.csproj"
            ]
          }
        }
      
    • startvs.cmd

      1
      2
      3
      
        @ECHO OFF
      
        %~dp0..\..\startvs.cmd %~dp0MyProject.slnf
      
This post is licensed under CC BY 4.0 by the author.