Skip to content

Libraries Build and VS Experience Changes #31823

Closed

Description

@Anipik

Libraries Build will now be using dotnet sdk outerbuild and innerbuild infrastructure to build the BCL.
Configurations.props file will no longer be required. TargetFrameworks can be directly used instead of BuildConfigurations.

I will just summarize the build and VS experience changes for the dotnet community.

Build Changes

  1. We are no longer overloading the configuration property. The only allowable configurations are Debug and Release. ConfigurationGroup property is replaced by Configuration.
  2. TargetGroup property has also been removed. We will use the Target Framework and TargetFrameworkSuffix(refers to the OSGroup in the TargetFrameworks if present) properties in the csproj file to specify the conditions. You can also still keep using TargetsWindows\Unix\Linux properties.
    BuildTargetFramework is the new property which will be used for vertical build. For Building Individual Projects, you can use either TargetFramework or BuildTargetFramework to build against a specific TargetFramework.
    The default is netcoreapp5.0.
    TargetFramework can only be used to build one project. It cannot be used to build more than one projects and it can contain an osgroup as well eg you can build the project /p:TargetFramework=netcoreapp5.0-windows_NT. It will result in sdk running only the innerBuild for specified framework.
    BuildTargetFramework can be used for a vertical build as well as for individual project build. In case of an individual project it will result in outerBuild triggering an innerBuild by setting the TargetFramework to best supported framework.
  3. BuildConfigurations are replaced by TargetFrameworks property. Currently we will always have to use TargetFrameworks property in our csprojs to specify the supported frameworks even if its only one. (TargetFramework in csproj file wont work)
  4. PackageConfigurations have also been removed. By default all TargetFrameworks will be included in the package. You can remove the TargetFramework from a package by specifically setting ExcludeFromPackage property = true for the specific targetFramework. Eg
<ExcludeFromPackage Condition="'$(TargetFramework)' != 'netstandard2.0'">true</ExcludeFromPackage>
  1. There hasn’t been any change in how we build our allConfigurations leg

VS Experience Changes

  1. Editor experience has improved as you will now able to choose the TargetFramework from the dropdown menu for individual files.
  2. By default, the vs builds all netcoreapp5.0 TargetFrameworks i.e if a project builds for netcoreapp5.0-WindowsNT, netcoreapp5.0-Unix, Building the project from the VS will result in building for both the target Frameworks.
    However, you can build for more TargetFrameworks by setting AdditionalBuildTargetFrameworks property.
  3. The testing experience is mostly the same i.e launch with -VS switch and debug or run tests using test explorer.

Some Benefits Besides Cleanup

  1. This is the first step towards enabling restore for src and ref csprojs and removing deprojs.
  2. We can use now common msbuild properties with coreclr and installer subsets eg Earlier we were using ConfigurationGroup and everything else was using Configuration.
  3. We can now enable running tests in VS for net472.
  4. The build is faster.

@ericstj @ViktorHofer @safern feel free to edit and add benefits.
PR making the change #1787

cc @danmosemsft

Activity

  1. added
    untriaged
    on Feb 5, 2020
  2. danmoseley commented on Feb 5, 2020

    @danmoseley
    Contributor

    Yay - especially for the Visual Studio improvements.

  3. ViktorHofer commented on Feb 5, 2020

    @ViktorHofer
    Member

    By default, the vs builds all netcoreapp5.0 targetFrameworks i.e if a project builds for netcoreapp5.0-windowsNT, netcoreapp5.0-unix, Building the project from the VS will result in building for both the target Frameworks.

    What about netstandard2.0 and 2.1? Aren't those implicit as well?

  4. pinned this issue on Feb 5, 2020
  5. safern commented on Feb 5, 2020

    @safern
    Member

    FYI: I just pinned the issue so that it is visible.

  6. changed the title [-]Build and VS Experience Changes due to the new build system[/-] [+]Libraries Build and VS Experience Changes due to the new build system[/+] on Feb 5, 2020
  7. changed the title [-]Libraries Build and VS Experience Changes due to the new build system[/-] [+]Libraries Build and VS Experience Changes[/+] on Feb 5, 2020
  8. ViktorHofer commented on Feb 5, 2020

    @ViktorHofer
    Member

    I changed the title to indicate that this is only about libraries (for now).

  9. removed
    untriaged
    on Feb 5, 2020
  10. EgorBo commented on Feb 6, 2020

    @EgorBo
    Member

    What's the current workflow to run a specific test suite?
    e.g. I follow the doc: https://github.com/dotnet/runtime/blob/master/docs/workflow/testing/libraries/testing.md#running-tests-on-the-command-line, e.g.:

    cd src/libraries/System.Collections.Immutable/tests && \
    dotnet msbuild /t:RebuildAndTest /p:Configuration=Release
    

    I get

    error NETSDK1013: The TargetFramework value '' was not recognized.
    

    if I specify /p:TargetFramework=netcoreapp5.0 I get

    error NETSDK1042: Could not load PlatformManifest from '/Users/egorbo/prj/runtime/artifacts/bin/testhost/netcoreapp5.0-OSX-Debug-x64/shared/Microsoft.NETCore.App/5.0.0/PlatformManifest.txt' because it did not exist.
    
  11. ViktorHofer commented on Feb 6, 2020

    @ViktorHofer
    Member

    Could not load PlatformManifest

    This sounds like you haven't built libraries with a Release configuration from root first: .\libraries.cmd -c Release.

  12. EgorBo commented on Feb 6, 2020

    @EgorBo
    Member

    Could not load PlatformManifest

    This sounds like you haven't built libraries with a Release configuration from root first: .\libraries.cmd -c Release.

    Didn't help 😢

  13. safern commented on Feb 6, 2020

    @safern
    Member

    error NETSDK1042: Could not load PlatformManifest from '/Users/egorbo/prj/runtime/artifacts/bin/testhost/netcoreapp5.0-OSX-Debug-x64/shared/Microsoft.NETCore.App/5.0.0/PlatformManifest.txt' because it did not exist.

    The path is searching on Debug. Can you confirm you're passing down /p:Configuration=Release

  14. adamsitnik commented on Feb 6, 2020

    @adamsitnik
    Member

    I got a very similar error.

    git clone https://github.com/dotnet/runtime
    cd runtime
    build -c Release
    cd .\src\libraries\System.Net.Sockets\
    dotnet msbuild /p:Configuration=Release
    PS C:\Projects\runtime\src\libraries\System.Net.Sockets> dotnet msbuild /p:Configuration=Release                                                        Microsoft (R) Build Engine version 16.3.0+0f4c62fea for .NET Core
    Copyright (C) Microsoft Corporation. All rights reserved.
    
      System.Runtime -> C:\Projects\runtime\artifacts\bin\System.Runtime\ref\netcoreapp5.0-Debug\System.Runtime.dll
      System.IO.FileSystem.Primitives -> C:\Projects\runtime\artifacts\bin\System.IO.FileSystem.Primitives\ref\netcoreapp5.0-Debug\System.IO.FileSystem.Primitives.dll
      System.Collections -> C:\Projects\runtime\artifacts\bin\System.Collections\ref\netcoreapp5.0-Debug\System.Collections.dll
      Microsoft.Win32.Primitives -> C:\Projects\runtime\artifacts\bin\Microsoft.Win32.Primitives\ref\netcoreapp5.0-Debug\Microsoft.Win32.Primitives.dll
      System.Runtime.InteropServices -> C:\Projects\runtime\artifacts\bin\System.Runtime.InteropServices\ref\netcoreapp5.0-Debug\System.Runtime.InteropServices.dll
      System.Memory -> C:\Projects\runtime\artifacts\bin\System.Memory\ref\netcoreapp5.0-Debug\System.Memory.dll
      System.Net.Primitives -> C:\Projects\runtime\artifacts\bin\System.Net.Primitives\ref\netcoreapp5.0-Debug\System.Net.Primitives.dll
      System.Net.Sockets -> C:\Projects\runtime\artifacts\bin\System.Net.Sockets\ref\netcoreapp5.0-Release\System.Net.Sockets.dll
      System.Net.Sockets -> C:\Projects\runtime\artifacts\bin\System.Net.Sockets\netcoreapp5.0-Windows_NT-Release\System.Net.Sockets.dll
    C:\Program Files\dotnet\sdk\3.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.ConflictResolution.targets(39,5): error NETSDK1042: Could not load PlatformManifest from 'C:\Projects\runtime\artifacts\bin\testhost\netcoreapp5.0-Windows_NT-Debug-x64\shared\Microsoft.NETCore.App\5.0.0\PlatformManifest.txt' because it did not exist. [C:\Projects\runtime\src\libraries\Common\tests\CoreFx.Private.TestUtilities\CoreFx.Private.TestUtilities.csproj]
    
  15. 18 remaining items

  16. danmoseley commented on Apr 3, 2020

    @danmoseley
    Contributor

    Since we're just talking about renaming test methods it should be possible for any one of us to review the whole thing. If there are distinct parts then separate commits might be helpful.

  17. danmoseley commented on Apr 8, 2020

    @danmoseley
    Contributor

    @alexvy86 now your PR is merged, how is the VS experience? Do most (all?) test projects run clean in VS now for you?

  18. alexvy86 commented on Apr 8, 2020

    @alexvy86
    Contributor

    @danmosemsft it's hard to say, I've only tried opening a few in VS, and lately I've been running into new issues with that. At some point I was able to run tests for System.Text.Json in VS, that's how I took some of the initial screenshots, but right now test discovery is failing.

    ---------- Starting test discovery ----------
    Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Testhost process exited with error: Error:
      An assembly specified in the application dependencies manifest (Microsoft.NETCore.App.deps.json) was not found:
        package: 'Microsoft.NETCore.App', version: '5.0.0'
        path: 'runtimes/rid/lib/netcoreapp0.0/System.ComponentModel.TypeConverter.dll'
    . Please check the diagnostic logs for more information.
       at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.ThrowOnTestHostExited(Boolean testHostExited)
       at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, String runSettings)
       at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
    ========== Test discovery aborted: 0 Tests found in 392 ms ==========
    

    System.ComponentModel.TypeConverter takes a ton of time discovering tests... Once I was able to debug one particular test, but ever since when I try to debug it, breakpoints won't get hit (they say symbols are not loaded for the project... but it is the project that I have open in VS!), and complains about missing symbols for something related to xUnit, after an Assert already failed.

    I'm not sure how much of this is messed up configuration in my machine/environment and how much related to changes in the repo. I'll keep playing around with all of this and post any updates.

  19. danmoseley commented on Apr 8, 2020

    @danmoseley
    Contributor

    OK, thanks. It would be great to enumerate issues and perhaps we can keep making progress.

  20. alexvy86 commented on Apr 8, 2020

    @alexvy86
    Contributor

    Of note, I haven't gone back to master, all of this is in the branch I created for the PR. I'll start testing back in master now that it got merged.

  21. danmoseley commented on Apr 8, 2020

    @danmoseley
    Contributor

    Note there were some recent changes to how building is done: #33821
    You may want to git clean -fdx after pulling, and use the new commands own.

  22. safern commented on Apr 8, 2020

    @safern
    Member

    System.ComponentModel.TypeConverter takes a ton of time discovering tests...

    Maybe you built coreclr in Debug mode?

    Note that you also need to install the latest daily build of the SDK once you pull from master as we updated the SDK we list in the global.json. https://github.com/dotnet/installer/blob/master/README.md#installers-and-binaries

  23. alexvy86 commented on Apr 8, 2020

    @alexvy86
    Contributor

    Maybe you built coreclr in Debug mode?

    I did at the beginning, yes, but after noticing that test runs in many projects were taking longer than I though they would, I noticed the issue and built the Release version. Tests started running faster, and I thought I was fine, but maybe something (in VS?) was still using the Debug version.

    I just installed the latest SDK after reading about it in the announcement, I'll keep playing around with the scenarios that I already saw working and report any problems I encounter.

  24. alexvy86 commented on Apr 8, 2020

    @alexvy86
    Contributor

    So I cleaned up with git clean -fdx, I pulled master, built CoreCLR in Release mode (.\build.cmd clr -c Release), then built the libraries in Debug mode (.\build.cmd libs), and 33 of them errored out complaining about missing Debug-mode artifacts from CoreCLR in \artifacts\bin\coreclr\Windows_NT.x64.Debug\. I thought working on the libraries should be possible building CoreCLR in Release mode, right?

    Now, System.Text.Json is one of the libraries that succeeded the build, so I then opened it in VS 16.5.2 (.\build.cmd -vs System.Text.Json), tried to build the solution in Debug mode through the context menu, and got warnings and errors about missing assemblies (most of them from the list of libraries whose build failed above, but also others):

    image

    I also tried building System.ComponentModel.TypeConverter from VS and got similar, if fewer, errors:

    image

    Just to get more data, I built the libraries in Release mode (\build.cmd libs -c Release) and that succeeded. But even then, building the System.Text.Json solution in VS (I tried Debug and Release this time) failed.

    I tried looking at commonalities for the library projects whose Debug build failed, and this is a shot in the dark but they all have this in their csproj file:

    <ItemGroup>
      <ReferenceFromRuntime Include="System.Private.CoreLib" />
    </ItemGroup>
    

    Since I read that CoreLib is pretty tied to the runtime and they need to be built in the same configuration, maybe that has something to do with it?

  25. safern commented on Apr 8, 2020

    @safern
    Member

    then built the libraries in Debug mode (.\build.cmd libs)

    I think you missed passing -runtimeConfiguration Release. Also you need to pass this to build.cmd -vs command, that way projects that have a ReferenceFromRuntime find the right coreclr path.

  26. Anipik commented on Apr 8, 2020

    @Anipik
    ContributorAuthor

    Some of the intellisense iand testing issues are resolved by #34721

  27. alexvy86 commented on Apr 9, 2020

    @alexvy86
    Contributor

    I think you missed passing -runtimeConfiguration Release. Also you need to pass this to build.cmd -vs command, that way projects that have a ReferenceFromRuntime find the right coreclr path.

    Ah, that's what -runtimeConfiguration is for, it makes sense now. It partially helped, the Debug-mode command line build of the libraries succeeded, but once in VS I get weird behavior (this is System.Text.Json):

    A Rebuild on the solution or any of the projects supposedly succeeds:

    1>------ Rebuild All started: Project: System.Text.Json (ref\System.Text.Json), Configuration: Debug Any CPU ------
    2>------ Rebuild All started: Project: TestUtilities, Configuration: Debug Any CPU ------
    1>System.Text.Json -> F:\forks\dotnet-runtime\artifacts\bin\System.Text.Json\ref\netcoreapp5.0-Debug\System.Text.Json.dll
    2>TestUtilities -> F:\forks\dotnet-runtime\artifacts\bin\TestUtilities\netcoreapp5.0-Debug\TestUtilities.dll
    3>------ Rebuild All started: Project: System.Text.Json (src\System.Text.Json), Configuration: Debug Any CPU ------
    3>System.Text.Json -> F:\forks\dotnet-runtime\artifacts\bin\System.Text.Json\netcoreapp5.0-Debug\System.Text.Json.dll
    4>------ Rebuild All started: Project: System.Text.Json.Tests, Configuration: Debug Any CPU ------
    4>System.Text.Json.Tests -> F:\forks\dotnet-runtime\artifacts\bin\System.Text.Json.Tests\netcoreapp5.0-Debug\System.Text.Json.Tests.dll
    ========== Rebuild All: 4 succeeded, 0 failed, 0 skipped ==========
    

    But a Build of the solution or any of the projects fails and shows these warnings/errors:

    image

    1>------ Build started: Project: System.Text.Json (ref\System.Text.Json), Configuration: Debug Any CPU ------
    2>------ Build started: Project: TestUtilities, Configuration: Debug Any CPU ------
    1>F:\forks\dotnet-runtime\src\libraries\System.Text.Json\ref\System.Text.Json.csproj : error NU1201: Project System.Memory is not compatible with netcoreapp5.0 (.NETCoreApp,Version=v5.0). Project System.Memory supports: net50 (.NETFramework,Version=v5.0)
    1>F:\forks\dotnet-runtime\src\libraries\System.Text.Json\ref\System.Text.Json.csproj : error NU1201: Project System.Runtime is not compatible with netcoreapp5.0 (.NETCoreApp,Version=v5.0). Project System.Runtime supports: net50 (.NETFramework,Version=v5.0)
    1>Done building project "System.Text.Json.csproj" -- FAILED.
    3>------ Build started: Project: System.Text.Json (src\System.Text.Json), Configuration: Debug Any CPU ------
    3>System.Text.Json -> F:\forks\dotnet-runtime\artifacts\bin\System.Text.Json\netcoreapp5.0-Debug\System.Text.Json.dll
    2>TestUtilities -> F:\forks\dotnet-runtime\artifacts\bin\TestUtilities\netcoreapp5.0-Debug\TestUtilities.dll
    4>------ Build started: Project: System.Text.Json.Tests, Configuration: Debug Any CPU ------
    4>System.Text.Json.Tests -> F:\forks\dotnet-runtime\artifacts\bin\System.Text.Json.Tests\netcoreapp5.0-Debug\System.Text.Json.Tests.dll
    ========== Build: 3 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    

    Even after a supposedly successful rebuild, Test Explorer is not reporting any tests, and if I click on Run All Tests it complains of a failed build.

    So I went to the two projects that complain about "not being compatible with netcoreapp5.0". I opened System.Memory with VS and building throws these issues (duplicate frameworks?):

    image

    System.Runtime throws these (a missing CompileDesignTime target, and looking for a Unix artifacts folder?):

    image

    Haven't been able to figure them out, so posting them here in case they ring a bell for anyone.

  28. alexvy86 commented on Apr 9, 2020

    @alexvy86
    Contributor

    Ah the "duplicate frameworks" issue is already tracked in #32205

  29. 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

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions