Skip to content

Doc enhancement: How can I quickly build the NuGet package for a single library that ships out of dotnet/runtime? #32249

Closed

Description

@ahsonkhan

If I need to build and test a particular package (say System.Text.Json), here is what I do:

  1. On a clean clone of the repo, run:

build.cmd -subsetCategory coreclr -c Release && build.cmd -subsetCategory libraries /p:CoreCLRConfiguration=Release -allconfigurations

  1. Wait ~10 minutes.

Once built, I can find it in E:\GitHub\Fork\runtime\artifacts\packages\Debug\Shipping (along with all the other packages), add the local directory to my NuGet.Config, reference it from a console app project, and then dogfood it. We should update and capture the dogfooding steps in docs.

Is there a better/faster way to do so and can we improve the inner dev loop for that, where I don't have to build all the packages?

cc @ViktorHofer, @maryamariyan, @safern

Activity

  1. added
    documentation
    on Feb 13, 2020
  2. added
    untriaged
    on Feb 13, 2020
  3. safern commented on Feb 13, 2020

    @safern
    Member

    Is there a better/faster way to do so and can we improve the inner dev loop for that, where I don't have to build all the packages?

    What we could do is introduce a property like PackageToBuild so that you do build.cmd -subsetCategory libraries -allConfigurations /p:PackageToBuild=System.Drawing.Common and then the allConfigurations leg, knows what to build only to build a single package and then build that package.

    The current way you can achieve that is by disabling BuildPackages

    <BuildPackages Condition="'$(BuildPackages)' == '' and '$(DirectoryToBuild)' == ''">true</BuildPackages>

    and commenting the following:

    <Project Include="src.builds" />
    <Project Include="shims\manual\*.csproj" />
    <Project Include="shims\ApiCompat.proj" Condition="'$(DotNetBuildFromSource)' != 'true' and '$(BuildTargetFramework)' == '$(NetCoreAppCurrent)'" />
    <Project Include="pretest.proj" Condition="'$(DotNetBuildFromSource)' != 'true' and '$(BuildAllConfigurations)' != 'true'" />

    Then you can afterwards just build the pkgproj of interest, but that is a lot of steps, introducing a property that does it for you would be ideal.

    cc: @ericstj @joperezr

  4. joperezr commented on Feb 13, 2020

    @joperezr
    Member

    As @safern say, all we need in order to build a package is to restore the targetting packs, and build the ref assemblies, so that is why what @safern is suggesting above is to comment out all of the build of the implementation since you only really care about one single library. The only other optimization you can do, is to also set

    <BuildNative Condition="'$(BuildNative)' == '' and '$(DirectoryToBuild)' == ''">true</BuildNative>

    to false since you don't really need to build native in order to build packages and that will save you quite some additional time.

  5. safern commented on Feb 13, 2020

    @safern
    Member

    to false since you don't really need to build native in order to build packages and that will save you quite some additional time.

    Well, some packages need to build the native stuff, no?

  6. joperezr commented on Feb 13, 2020

    @joperezr
    Member

    nope :). IIRC the only native shim we package is for System.IO.Ports and I believe that this is a separate package entirely. BuildNative will only build clrcompression, and that guy only gets packaged on Microsoft.NETCore.App, so library OOB packages shouldn't need it.

  7. safern commented on Feb 13, 2020

    @safern
    Member

    IIRC the only native shim we package is for System.IO.Ports and I believe that this is a separate package entirely

    Right.

    BuildNative will only build clrcompression, and that guy only gets packaged on Microsoft.NETCore.App, so library OOB packages shouldn't need it.

    Ah, for windows, that's true, I was thinking of Crypto packages, but those shims ship inbox as part of the framework.

  8. removed
    untriaged
    on Feb 24, 2020
  9. added this to the 5.0 milestone on Feb 24, 2020
  10. ericstj commented on Feb 24, 2020

    @ericstj
    Member

    You can build individual pkgprojs, assuming all ref and redist are available (as mentioned above). This will get easier once we stop relying on the ref and redist pass for non-netcoreappcurrent.

  11. krwq commented on Apr 30, 2020

    @krwq
    Member

    would be nice if we made dotnet pack work in our repo (even if targets are hacked and it's actually not using dotnet utils)

  12. ericstj commented on Apr 30, 2020

    @ericstj
    Member

    WRT dotnet pack we could tackle that with dotnet/arcade#1033, along with eliminating pkgroj and making our packages build from outer build of our src projects.

    An ugly hack would be to have a Pack target defined in our src csprojs that just calls build on the pkgproj if it exists.

  13. joperezr commented on Apr 30, 2020

    @joperezr
    Member

    Also just to update the instructions @safern and I provided above some time ago, there have been changes in the infrastructure so those are no longer up-to-date, but the good news is that it is much easier now to build one single package without the need to modify temporarily any source files. So if you are in master branch latest, and in a clean clone, all you have to do is to first build all targetting packs with:

    build.cmd -s clr.corelib+libs.depprojs+libs.ref -rc release -allConfigurations
    

    That shouldn't take long (takes about 3-5 mins on my machine depending on NuGet restore). After that you should be able to build all configurations for a specific library, like for example:

    cd src\libraries\System.DirectoryServices.Protocols\
    dotnet build src\System.DirectoryServices.Protocols.csproj /t:rebuild /p:BuildAllConfigurations=true
    

    and finally you should also now be able to build the package itself, by running:

    dotnet msbuild pkg\System.DirectoryServices.Protocols.pkgproj /t:rebuild
    

    As long as you are only working with one library and don't really care about running tests (as running tests will require building the whole clr and libs runtime) then I recommend this workflow as a fast-paced way to be able to open library solutions in VS and have all building as expected as well as being able to build all configurations and the package (if building an OOB assembly)

  14. safern commented on Apr 30, 2020

    @safern
    Member

    Thanks, @joperezr for updating the instructions.

    That shouldn't take long (takes about 3-5 mins on my machine depending on NuGet restore). After that you should be able to build all configurations for a specific library, like for example:

    I think this step shouldn't be necessary right? as building the pkgproj will build the ref and src for all configurations?

  15. ericstj commented on Apr 30, 2020

    @ericstj
  16. joperezr commented on Apr 30, 2020

    @joperezr
    Member

    The thing I've seen is that if you use the workflow I proposed above, building the pkgproj won't call restore on the ref and src projects, which we now need to do, so it is just a way to make sure restore is called (notice how I used dotnet build and not dotnet msbuild since I wanted restore to happen)

  17. joperezr commented on Apr 30, 2020

    @joperezr
    Member

    I haven't tried skipping my second step and just doing dotnet build pkg\System.DirectoryServices.Protocols.pkgproj but that probably works as well.

  18. safern commented on Apr 30, 2020

    @safern
    Member

    Right, that is what I was about to ask 😄.

  19. ViktorHofer commented on May 1, 2020

    @ViktorHofer
    Member

    FWIW

    1. You can omit the -s if the subsets are the first argument.
    2. You shouldn't need to specify /t:Rebuild. In case you need it, dotnet build --no-incremental is the public facing switch for that.
  20. self-assigned this
    on Jul 20, 2020
  21. ViktorHofer commented on Jul 30, 2020

    @ViktorHofer
    Member

    Fixed (documented) by b7f809d: https://github.com/dotnet/runtime/blob/b7f809d7e37f8dade15fc6aa588565d3f0ee20a6/docs/workflow/building/libraries/README.md#build-packages

    TL;DR:

    build.cmd libs
    dotnet pack src\libraries\System.Text.Json\src\
    

    is sufficient now. No allconfigurations build needed anymore.

  22. ghost locked as resolved and limited conversation to collaborators on Dec 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-Infrastructure-librariesdocumentation

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions