diff --git a/.vsts-ci.yml b/.vsts-ci.yml index 346fd082fcfb..5f26c7de9bea 100644 --- a/.vsts-ci.yml +++ b/.vsts-ci.yml @@ -168,6 +168,7 @@ stages: enableSigningValidation: false enableNugetValidation: false enableSourceLinkValidation: false + publishInstallersAndChecksums: true SDLValidationParameters: enable: false params: ' -SourceToolsList @("policheck","credscan") diff --git a/documentation/general/tab-completion.md b/documentation/general/tab-completion.md index 4687e897e5db..a4dd2ffba9d0 100644 --- a/documentation/general/tab-completion.md +++ b/documentation/general/tab-completion.md @@ -27,19 +27,8 @@ If you just installed `dotnet` you may see the first-run output: Welcome to .NET Core! --------------------- Learn more about .NET Core: https://aka.ms/dotnet-docs -Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli-docs - -Telemetry ---------- -The .NET Core tools collect usage data in order to help us improve your experience. The data is anonymous and doesn't include command-line arguments. The data is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell. - -Read more about .NET Core CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry - -Configuring... --------------- -A command is running to populate your local package cache to improve restore speed and enable offline access. This command takes up to one minute to complete and only runs once. -Decompressing 100% 4936 ms -Expanding 100% 17195 ms +... +... ``` You should see the following ouput (perhaps coming at the end of the first-run output). This indicates that `dotnet` is resolving to a v2.0 installation that supports completion. diff --git a/src/Assets/TestProjects/NETCoreCppClApp/NETCoreCppCliTest/NETCoreCppCliTest.vcxproj b/src/Assets/TestProjects/NETCoreCppClApp/NETCoreCppCliTest/NETCoreCppCliTest.vcxproj index c4a1ef7b05f9..8f6311bdd38a 100644 --- a/src/Assets/TestProjects/NETCoreCppClApp/NETCoreCppCliTest/NETCoreCppCliTest.vcxproj +++ b/src/Assets/TestProjects/NETCoreCppClApp/NETCoreCppCliTest/NETCoreCppCliTest.vcxproj @@ -13,7 +13,7 @@ 16.0 {CF5DA8D7-1FDF-4E8F-AFE6-450BE16E906A} - netcoreapp3.1 + net5.0 ManagedCProj NETCoreCppCliTest 10.0 diff --git a/src/Assets/TestProjects/NetCoreCsharpAppReferenceCppCliLib/CSConsoleApp/CSConsoleApp.csproj b/src/Assets/TestProjects/NetCoreCsharpAppReferenceCppCliLib/CSConsoleApp/CSConsoleApp.csproj index bcd4e2dbe3be..72494d46c1b8 100644 --- a/src/Assets/TestProjects/NetCoreCsharpAppReferenceCppCliLib/CSConsoleApp/CSConsoleApp.csproj +++ b/src/Assets/TestProjects/NetCoreCsharpAppReferenceCppCliLib/CSConsoleApp/CSConsoleApp.csproj @@ -1,7 +1,7 @@ Exe - netcoreapp3.1 + net5.0 x64 x64 diff --git a/src/Cli/Microsoft.DotNet.Configurer/LocalizableStrings.resx b/src/Cli/Microsoft.DotNet.Configurer/LocalizableStrings.resx index 181086c5f5f9..e5d77533d328 100644 --- a/src/Cli/Microsoft.DotNet.Configurer/LocalizableStrings.resx +++ b/src/Cli/Microsoft.DotNet.Configurer/LocalizableStrings.resx @@ -128,7 +128,7 @@ SDK Version: {1} Telemetry --------- -The .NET tools collect usage data in order to help us improve your experience. The data is anonymous. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell. +The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell. Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry diff --git a/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.cs.xlf b/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.cs.xlf index f62cba5ac35a..0e9164b30a7e 100644 --- a/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.cs.xlf +++ b/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.cs.xlf @@ -44,7 +44,7 @@ SDK Version: {1} Telemetry --------- -The .NET tools collect usage data in order to help us improve your experience. The data is anonymous. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell. +The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell. Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry Telemetrie diff --git a/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.de.xlf b/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.de.xlf index 7d9ca5bb9c72..623f23148e34 100644 --- a/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.de.xlf +++ b/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.de.xlf @@ -44,7 +44,7 @@ SDK Version: {1} Telemetry --------- -The .NET tools collect usage data in order to help us improve your experience. The data is anonymous. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell. +The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell. Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry Telemetrie diff --git a/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.es.xlf b/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.es.xlf index 0ce990347b34..c86cd7118a97 100644 --- a/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.es.xlf +++ b/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.es.xlf @@ -44,7 +44,7 @@ SDK Version: {1} Telemetry --------- -The .NET tools collect usage data in order to help us improve your experience. The data is anonymous. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell. +The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell. Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry Telemetría @@ -56,4 +56,4 @@ Lea más sobre la telemetría de las herramientas de la CLI de .NET Core: https: - + \ No newline at end of file diff --git a/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.fr.xlf b/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.fr.xlf index f160d89beac2..f933ec73ba41 100644 --- a/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.fr.xlf +++ b/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.fr.xlf @@ -44,7 +44,7 @@ SDK Version: {1} Telemetry --------- -The .NET tools collect usage data in order to help us improve your experience. The data is anonymous. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell. +The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell. Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry Télémétrie diff --git a/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.it.xlf b/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.it.xlf index d39d7b1716b6..fc6d3609a14c 100644 --- a/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.it.xlf +++ b/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.it.xlf @@ -44,7 +44,7 @@ SDK Version: {1} Telemetry --------- -The .NET tools collect usage data in order to help us improve your experience. The data is anonymous. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell. +The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell. Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry Telemetria diff --git a/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.ja.xlf b/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.ja.xlf index 57bc29377a5e..9217b3561b81 100644 --- a/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.ja.xlf +++ b/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.ja.xlf @@ -44,7 +44,7 @@ SDK Version: {1} Telemetry --------- -The .NET tools collect usage data in order to help us improve your experience. The data is anonymous. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell. +The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell. Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry テレメトリ diff --git a/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.ko.xlf b/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.ko.xlf index 7c0d5dcf8bdd..7ddb65f20baf 100644 --- a/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.ko.xlf +++ b/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.ko.xlf @@ -44,7 +44,7 @@ SDK Version: {1} Telemetry --------- -The .NET tools collect usage data in order to help us improve your experience. The data is anonymous. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell. +The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell. Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry 원격 분석 diff --git a/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.pl.xlf b/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.pl.xlf index 4104c467f4a3..0b7cd44b6f13 100644 --- a/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.pl.xlf +++ b/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.pl.xlf @@ -44,7 +44,7 @@ SDK Version: {1} Telemetry --------- -The .NET tools collect usage data in order to help us improve your experience. The data is anonymous. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell. +The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell. Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry Telemetria diff --git a/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.pt-BR.xlf b/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.pt-BR.xlf index 8257140f8d88..bf069f7b1d18 100644 --- a/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.pt-BR.xlf +++ b/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.pt-BR.xlf @@ -44,7 +44,7 @@ SDK Version: {1} Telemetry --------- -The .NET tools collect usage data in order to help us improve your experience. The data is anonymous. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell. +The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell. Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry Telemetria! diff --git a/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.ru.xlf b/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.ru.xlf index 326cc09fb9aa..f1d323a8ea10 100644 --- a/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.ru.xlf +++ b/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.ru.xlf @@ -44,7 +44,7 @@ SDK Version: {1} Telemetry --------- -The .NET tools collect usage data in order to help us improve your experience. The data is anonymous. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell. +The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell. Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry Телеметрия diff --git a/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.tr.xlf b/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.tr.xlf index ae4d27370bcb..4edac1181dd3 100644 --- a/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.tr.xlf +++ b/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.tr.xlf @@ -44,7 +44,7 @@ SDK Version: {1} Telemetry --------- -The .NET tools collect usage data in order to help us improve your experience. The data is anonymous. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell. +The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell. Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry Telemetri diff --git a/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.zh-Hans.xlf b/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.zh-Hans.xlf index 63f2456f905a..74a85b04cd5f 100644 --- a/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.zh-Hans.xlf +++ b/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.zh-Hans.xlf @@ -44,7 +44,7 @@ SDK Version: {1} Telemetry --------- -The .NET tools collect usage data in order to help us improve your experience. The data is anonymous. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell. +The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell. Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry 遥测 diff --git a/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.zh-Hant.xlf b/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.zh-Hant.xlf index 2c289a0a1e52..5497b99f9786 100644 --- a/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.zh-Hant.xlf +++ b/src/Cli/Microsoft.DotNet.Configurer/xlf/LocalizableStrings.zh-Hant.xlf @@ -44,7 +44,7 @@ SDK Version: {1} Telemetry --------- -The .NET tools collect usage data in order to help us improve your experience. The data is anonymous. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell. +The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell. Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry 遙測 diff --git a/src/Resolvers/Microsoft.DotNet.MSBuildSdkResolver/Microsoft.DotNet.MSBuildSdkResolver.csproj b/src/Resolvers/Microsoft.DotNet.MSBuildSdkResolver/Microsoft.DotNet.MSBuildSdkResolver.csproj index a06a92563543..f98311fdca8b 100644 --- a/src/Resolvers/Microsoft.DotNet.MSBuildSdkResolver/Microsoft.DotNet.MSBuildSdkResolver.csproj +++ b/src/Resolvers/Microsoft.DotNet.MSBuildSdkResolver/Microsoft.DotNet.MSBuildSdkResolver.csproj @@ -15,7 +15,7 @@ - + @@ -33,8 +33,36 @@ + - + - + + + + + + + + + + x86/hostfxr.dll + PreserveNewest + + + x64/hostfxr.dll + PreserveNewest + + + + + + + + true + + + + + \ No newline at end of file diff --git a/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/GivenADependencyContextBuilder.cs b/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/GivenADependencyContextBuilder.cs index 943ede651497..31b3bee2408c 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/GivenADependencyContextBuilder.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/GivenADependencyContextBuilder.cs @@ -56,7 +56,7 @@ public void ItBuildsDependencyContextsFromProjectLockFiles( i => true); ProjectContext projectContext = lockFile.CreateProjectContext( - FrameworkConstants.CommonFrameworks.NetCoreApp10, + FrameworkConstants.CommonFrameworks.NetCoreApp10.GetShortFolderName(), runtime, Constants.DefaultPlatformLibrary, runtimeFrameworks: null, @@ -254,7 +254,7 @@ private DependencyContext BuildDependencyContextWithReferenceAssemblies(bool use }; ProjectContext projectContext = lockFile.CreateProjectContext( - FrameworkConstants.CommonFrameworks.NetCoreApp10, + FrameworkConstants.CommonFrameworks.NetCoreApp10.GetShortFolderName(), runtime: null, platformLibraryName: Constants.DefaultPlatformLibrary, runtimeFrameworks: null, @@ -306,7 +306,7 @@ public void ItCanGenerateTheRuntimeFallbackGraph() new ITaskItem[] { }); ProjectContext projectContext = lockFile.CreateProjectContext( - FrameworkConstants.CommonFrameworks.NetCoreApp10, + FrameworkConstants.CommonFrameworks.NetCoreApp10.GetShortFolderName(), runtime: null, platformLibraryName: Constants.DefaultPlatformLibrary, runtimeFrameworks: null, diff --git a/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/GivenAProjectContext.cs b/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/GivenAProjectContext.cs index eabef7cd2bae..37d74bd8fd6f 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/GivenAProjectContext.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/GivenAProjectContext.cs @@ -19,7 +19,7 @@ public void ItComputesExcludeFromPublishList() { LockFile lockFile = TestLockFiles.GetLockFile("dependencies.withgraphs"); ProjectContext projectContext = lockFile.CreateProjectContext( - FrameworkConstants.CommonFrameworks.NetStandard16, + FrameworkConstants.CommonFrameworks.NetStandard16.GetShortFolderName(), runtime: null, Constants.DefaultPlatformLibrary, runtimeFrameworks: null, diff --git a/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/GivenAResolvePackageDependenciesTask.cs b/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/GivenAResolvePackageDependenciesTask.cs index 36e0eb9f81ec..d770c7b9f246 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/GivenAResolvePackageDependenciesTask.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/GivenAResolvePackageDependenciesTask.cs @@ -94,7 +94,7 @@ public void ItAssignsValidParentTargetsAndPackages(string projectName) var task = GetExecutedTaskFromPrefix(projectName, out lockFile); // set of valid targets and packages - HashSet validTargets = new HashSet(lockFile.Targets.Select(x => x.Name)); + HashSet validTargets = new HashSet(lockFile.PackageSpec.TargetFrameworks.Select(tf => tf.TargetAlias)); HashSet validPackages = new HashSet(lockFile.Libraries.Select(x => $"{x.Name}/{x.Version.ToNormalizedString()}")); Func allValidParentTarget = @@ -159,7 +159,7 @@ public void ItAssignsExpectedTopLevelDependencies() topLevels.All(t => t.ItemSpec == "LibA/1.2.3").Should().BeTrue(); topLevels.Select(t => t.GetMetadata(MetadataKeys.ParentTarget)) .Should().Contain(new string[] { - ".NETCoreApp,Version=v1.0", ".NETCoreApp,Version=v1.0/osx.10.11-x64" + "netcoreapp1.0", "netcoreapp1.0/osx.10.11-x64" }); } @@ -236,14 +236,14 @@ public void ItAssignsExpectedTopLevelDependenciesFromAllTargets() topLevels.Where(t => t.ItemSpec == "LibA/1.2.3") .Select(t => t.GetMetadata(MetadataKeys.ParentTarget)) .Should().Contain(new string[] { - ".NETCoreApp,Version=v1.0", ".NETCoreApp,Version=v1.0/osx.10.11-x64" + "netcoreapp1.0", "netcoreapp1.0/osx.10.11-x64" }); topLevels.Where(t => t.ItemSpec == "LibD/1.2.3").Count().Should().Be(1); topLevels.Where(t => t.ItemSpec == "LibD/1.2.3") .Select(t => t.GetMetadata(MetadataKeys.ParentTarget)) .Should().Contain(new string[] { - ".NETCoreApp,Version=v1.0" + "netcoreapp1.0" }); } @@ -355,11 +355,11 @@ public void ItAssignsPackageDependenciesMetadata() var packageDep = task.PackageDependencies.Where(t => t.ItemSpec == "LibA/1.2.3").First(); packageDep.GetMetadata(MetadataKeys.ParentPackage).Should().BeEmpty(); - packageDep.GetMetadata(MetadataKeys.ParentTarget).Should().Be(".NETCoreApp,Version=v1.0"); + packageDep.GetMetadata(MetadataKeys.ParentTarget).Should().Be("netcoreapp1.0"); packageDep = task.PackageDependencies.Where(t => t.ItemSpec == "LibB/1.2.3").First(); packageDep.GetMetadata(MetadataKeys.ParentPackage).Should().Be("LibA/1.2.3"); - packageDep.GetMetadata(MetadataKeys.ParentTarget).Should().Be(".NETCoreApp,Version=v1.0"); + packageDep.GetMetadata(MetadataKeys.ParentTarget).Should().Be("netcoreapp1.0"); // LibC has both a package and project that depend on it var packageDeps = task.PackageDependencies.Where(t => t.ItemSpec == "LibC/1.2.3"); @@ -367,7 +367,7 @@ public void ItAssignsPackageDependenciesMetadata() packageDeps.Select(t => t.GetMetadata(MetadataKeys.ParentPackage)) .Should().Contain(new string[] { "LibB/1.2.3", "ClassLibP/1.2.3" }); packageDeps.Select(t => t.GetMetadata(MetadataKeys.ParentTarget)) - .Should().OnlyContain(s => s == ".NETCoreApp,Version=v1.0"); + .Should().OnlyContain(s => s == "netcoreapp1.0"); } [Fact] @@ -468,7 +468,7 @@ public void ItAssignsFileDependenciesMetadata() fileDeps.Select(t => t.GetMetadata(MetadataKeys.ParentPackage)) .Should().OnlyContain(s => s == "LibB/1.2.3"); fileDeps.Select(t => t.GetMetadata(MetadataKeys.ParentTarget)) - .Should().Contain(new string[] { ".NETCoreApp,Version=v1.0", ".NETCoreApp,Version=v1.0/osx.10.11-x64" }); + .Should().Contain(new string[] { "netcoreapp1.0", "netcoreapp1.0/osx.10.11-x64" }); } } } @@ -600,8 +600,8 @@ public void ItAddsAnalyzerMetadataAndFileDependencies() "analyzers/dotnet/vb/Microsoft.CodeAnalysis.VisualBasic.Analyzers.dll", }; var expectedTargets = new string[] { - ".NETCoreApp,Version=v1.0", - ".NETCoreApp,Version=v1.0/osx.10.11-x64" + "netcoreapp1.0", + "netcoreapp1.0/osx.10.11-x64" }; foreach (var analyzer in analyzers) @@ -681,8 +681,8 @@ public void ItFiltersAnalyzersByProjectLanguage() fileDefns.Count().Should().Be(3); var expectedTargets = new string[] { - ".NETCoreApp,Version=v1.0", - ".NETCoreApp,Version=v1.0/osx.10.11-x64" + "netcoreapp1.0", + "netcoreapp1.0/osx.10.11-x64" }; foreach (var analyzer in expectIncluded) @@ -749,11 +749,11 @@ public void ItUsesResolvedPackageVersionFromSameTarget() // Dep.Lib.Chi has version range [4.0.0, 5.0.0), but the version assigned // is that of the library in the same target - chiDeps.Where(t => t.GetMetadata(MetadataKeys.ParentTarget) == ".NETCoreApp,Version=v1.0") + chiDeps.Where(t => t.GetMetadata(MetadataKeys.ParentTarget) == "netcoreapp1.0") .Select(t => t.ItemSpec) .First().Should().Be("Dep.Lib.Chi/4.0.0"); - chiDeps.Where(t => t.GetMetadata(MetadataKeys.ParentTarget) == ".NETCoreApp,Version=v1.0/osx.10.11-x64") + chiDeps.Where(t => t.GetMetadata(MetadataKeys.ParentTarget) == "netcoreapp1.0/osx.10.11-x64") .Select(t => t.ItemSpec) .First().Should().Be("Dep.Lib.Chi/4.1.0"); } diff --git a/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/GivenAnAssetsFileResolver.cs b/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/GivenAnAssetsFileResolver.cs index 319c03d7aeeb..45be9f5886b0 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/GivenAnAssetsFileResolver.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/GivenAnAssetsFileResolver.cs @@ -24,7 +24,7 @@ public void ItResolvesAssembliesFromProjectLockFiles(string projectName, string { LockFile lockFile = TestLockFiles.GetLockFile(projectName); ProjectContext projectContext = lockFile.CreateProjectContext( - FrameworkConstants.CommonFrameworks.NetCoreApp10, + FrameworkConstants.CommonFrameworks.NetCoreApp10.GetShortFolderName(), runtime, Constants.DefaultPlatformLibrary, runtimeFrameworks: null, @@ -44,7 +44,7 @@ public void ItResolvesAssembliesFromProjectLockFilesWithStoreLayout(string proje { LockFile lockFile = TestLockFiles.GetLockFile(projectName); ProjectContext projectContext = lockFile.CreateProjectContext( - FrameworkConstants.CommonFrameworks.NetCoreApp10, + FrameworkConstants.CommonFrameworks.NetCoreApp10.GetShortFolderName(), runtime, Constants.DefaultPlatformLibrary, runtimeFrameworks: null, diff --git a/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/GivenThatWeWantToGetDependenciesViaDesignTimeBuild.cs b/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/GivenThatWeWantToGetDependenciesViaDesignTimeBuild.cs index c454cf4a50b4..84e2088d439a 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/GivenThatWeWantToGetDependenciesViaDesignTimeBuild.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/GivenThatWeWantToGetDependenciesViaDesignTimeBuild.cs @@ -14,7 +14,7 @@ public void ItShouldNotReturnPackagesWithUnknownTypes() { var task = new PreprocessPackageDependenciesDesignTime { - TargetFrameworkMoniker = ".Net Framework,Version=v4.5", + TargetFramework = "net45", DefaultImplicitPackages = string.Empty, PackageDefinitions = new ITaskItem[] { @@ -44,13 +44,13 @@ public void ItShouldNotReturnPackagesWithUnknownTypes() itemSpec: "mockPackageNoType/1.0.0", metadata: new Dictionary { - { MetadataKeys.ParentTarget, ".Net Framework,Version=v4.5" } + { MetadataKeys.ParentTarget, "net45" } }), new MockTaskItem( itemSpec: "mockPackageUnknown/1.0.0", metadata: new Dictionary { - { MetadataKeys.ParentTarget, ".Net Framework,Version=v4.5" } + { MetadataKeys.ParentTarget, "net45" } }) } }; @@ -65,7 +65,7 @@ public void ItShouldReturnUnresolvedPackageDependenciesWithTypePackage() { var task = new PreprocessPackageDependenciesDesignTime { - TargetFrameworkMoniker = ".Net Framework,Version=v4.5", + TargetFramework = "net45", DefaultImplicitPackages = string.Empty, PackageDefinitions = new ITaskItem[] { @@ -87,7 +87,7 @@ public void ItShouldReturnUnresolvedPackageDependenciesWithTypePackage() itemSpec: "mockPackageUnresolved/1.0.0", metadata: new Dictionary { - { MetadataKeys.ParentTarget, ".Net Framework,Version=v4.5" } + { MetadataKeys.ParentTarget, "net45" } }) } }; @@ -111,7 +111,7 @@ public void ItShouldIdentifyDefaultImplicitPackages() { var task = new PreprocessPackageDependenciesDesignTime { - TargetFrameworkMoniker = ".Net Framework,Version=v4.5", + TargetFramework = "net45", DefaultImplicitPackages = "DefaultImplicit", PackageDefinitions = new ITaskItem[] { @@ -132,7 +132,7 @@ public void ItShouldIdentifyDefaultImplicitPackages() itemSpec: "DefaultImplicit/1.0.0", metadata: new Dictionary { - { MetadataKeys.ParentTarget, ".Net Framework,Version=v4.5" } + { MetadataKeys.ParentTarget, "net45" } }) } }; @@ -150,7 +150,7 @@ public void ItShouldIgnoreAllDependenciesWithTypeNotEqualToPackageOrUnresolved() { var task = new PreprocessPackageDependenciesDesignTime { - TargetFrameworkMoniker = ".Net Framework,Version=v4.5", + TargetFramework = "net45", DefaultImplicitPackages = string.Empty, PackageDefinitions = new ITaskItem[] { new MockTaskItem( @@ -239,49 +239,49 @@ public void ItShouldIgnoreAllDependenciesWithTypeNotEqualToPackageOrUnresolved() itemSpec: "mockPackageExternalProject/1.0.0", metadata: new Dictionary { - { MetadataKeys.ParentTarget, ".Net Framework,Version=v4.5" } + { MetadataKeys.ParentTarget, "net45" } }), new MockTaskItem( itemSpec: "mockPackageProject/1.0.0", metadata: new Dictionary { - { MetadataKeys.ParentTarget, ".Net Framework,Version=v4.5" } + { MetadataKeys.ParentTarget, "net45" } }), new MockTaskItem( itemSpec: "mockPackageContent/1.0.0", metadata: new Dictionary { - { MetadataKeys.ParentTarget, ".Net Framework,Version=v4.5" } + { MetadataKeys.ParentTarget, "net45" } }), new MockTaskItem( itemSpec: "mockPackageAssembly/1.0.0", metadata: new Dictionary { - { MetadataKeys.ParentTarget, ".Net Framework,Version=v4.5" } + { MetadataKeys.ParentTarget, "net45" } }), new MockTaskItem( itemSpec: "mockPackageFrameworkAssembly/1.0.0", metadata: new Dictionary { - { MetadataKeys.ParentTarget, ".Net Framework,Version=v4.5" } + { MetadataKeys.ParentTarget, "net45" } }), new MockTaskItem( itemSpec: "mockPackageDiagnostic/1.0.0", metadata: new Dictionary { - { MetadataKeys.ParentTarget, ".Net Framework,Version=v4.5" } + { MetadataKeys.ParentTarget, "net45" } }), new MockTaskItem( itemSpec: "mockPackageWinmd/1.0.0", metadata: new Dictionary { - { MetadataKeys.ParentTarget, ".Net Framework,Version=v4.5" } + { MetadataKeys.ParentTarget, "net45" } }), new MockTaskItem( itemSpec: "mockPackageReference/1.0.0", metadata: new Dictionary { - { MetadataKeys.ParentTarget, ".Net Framework,Version=v4.5" } + { MetadataKeys.ParentTarget, "net45" } }) } }; @@ -296,7 +296,7 @@ public void ItShouldOnlyReturnPackagesInTheSpecifiedTarget() { var task = new PreprocessPackageDependenciesDesignTime { - TargetFrameworkMoniker = ".Net Framework,Version=v4.5", + TargetFramework = "net45", DefaultImplicitPackages = string.Empty, PackageDefinitions = new ITaskItem[] { new MockTaskItem( @@ -325,13 +325,13 @@ public void ItShouldOnlyReturnPackagesInTheSpecifiedTarget() itemSpec: "Package1/1.0.0", metadata: new Dictionary { - { MetadataKeys.ParentTarget, ".Net Framework,Version=v4.5" } + { MetadataKeys.ParentTarget, "net45" } }), new MockTaskItem( itemSpec: "Package2/1.0.0", metadata: new Dictionary { - { MetadataKeys.ParentTarget, ".Net Framework,Version=v4.6" } + { MetadataKeys.ParentTarget, "net46" } }) } }; @@ -348,7 +348,7 @@ public void ItShouldOnlyReturnTopLevelPackages() { var task = new PreprocessPackageDependenciesDesignTime { - TargetFrameworkMoniker = ".Net Framework,Version=v4.5", + TargetFramework = "net45", DefaultImplicitPackages = string.Empty, PackageDefinitions = new ITaskItem[] { new MockTaskItem( @@ -377,13 +377,13 @@ public void ItShouldOnlyReturnTopLevelPackages() itemSpec: "Package1/1.0.0", metadata: new Dictionary { - { MetadataKeys.ParentTarget, ".Net Framework,Version=v4.5" } + { MetadataKeys.ParentTarget, "net45" } }), new MockTaskItem( itemSpec: "ChildPackage1/1.0.0", metadata: new Dictionary { - { MetadataKeys.ParentTarget, ".Net Framework,Version=v4.5" }, + { MetadataKeys.ParentTarget, "net45" }, { MetadataKeys.ParentPackage, "Package1/1.0.0" } }) } diff --git a/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/LockFileSnippets.cs b/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/LockFileSnippets.cs index faf3b69af72f..ae4672720cb1 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/LockFileSnippets.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/LockFileSnippets.cs @@ -23,11 +23,57 @@ public static string CreateLockFileSnippet( ""targets"": {{{string.Join(",", targets)}}}, ""libraries"": {{{string.Join(",", libraries)}}}, {GetLogsPart(logs)} - ""projectFileDependencyGroups"": {{{string.Join(",", projectFileDependencyGroups)}}} - + ""projectFileDependencyGroups"": {{{string.Join(",", projectFileDependencyGroups)}}}, + {LockFileProjectSection} }}"; } + private static string LockFileProjectSection = @" 'project': { + 'version': '1.0.0', + 'restore': { + 'projectUniqueName': 'C:\\git\\repro\\consoletest\\consoletest.csproj', + 'projectName': 'consoletest', + 'projectPath': 'C:\\git\\repro\\consoletest\\consoletest.csproj', + 'packagesPath': 'C:\\Users\\username\\.nuget\\packages\\', + 'outputPath': 'C:\\git\\repro\\consoletest\\obj\\', + 'projectStyle': 'PackageReference', + 'fallbackFolders': [], + 'configFilePaths': [ + 'C:\\Users\\username\\AppData\\Roaming\\NuGet\\NuGet.Config' + ], + 'originalTargetFrameworks': [ + 'netcoreapp1.0' + ], + 'sources': { + 'https://api.nuget.org/v3/index.json': {} + }, + 'frameworks': { + 'netcoreapp1.0': { + 'targetAlias': 'netcoreapp1.0', + 'projectReferences': {} + } + }, + 'warningProperties': { + 'warnAsError': [ + 'NU1605' + ] + } + }, + 'frameworks': { + 'netcoreapp1.0': { + 'targetAlias': 'netcoreapp1.0', + 'dependencies': { + 'Microsoft.NETCore.App': { + 'target': 'Package', + 'version': '[1.0.5, )', + 'autoReferenced': true + } + }, + 'runtimeIdentifierGraphPath': 'C:\\git\\dotnet-sdk\\artifacts\\bin\\redist\\Debug\\dotnet\\sdk\\5.0.100-dev\\RuntimeIdentifierGraph.json' + } + } + }".Replace('\'', '"'); + private static string GetLogsPart(string[] logs) => logs == null ? string.Empty : $@" ""logs"": [{string.Join(",", logs)}], "; @@ -209,4 +255,4 @@ private static string ToStringList(params string[] members) #endregion } -} \ No newline at end of file +} diff --git a/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/LockFiles/all.asset.types.project.lock.json b/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/LockFiles/all.asset.types.project.lock.json index 5805a694353b..46a99924f612 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/LockFiles/all.asset.types.project.lock.json +++ b/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/LockFiles/all.asset.types.project.lock.json @@ -1,5 +1,5 @@ { - "version": 2, + "version": 3, "targets": { ".NETCoreApp,Version=v1.0": { "Libuv/1.9.0": { @@ -210,9 +210,52 @@ "System.Spatial >= 5.7.0" ] }, - "tools": {}, - "projectFileToolGroups": {}, "packageFolders": { "C:\\.nuget\\packages\\": {} + }, + "project": { + "version": "1.0.0", + "restore": { + "projectUniqueName": "C:\\git\\repro\\consoletest\\consoletest.csproj", + "projectName": "consoletest", + "projectPath": "C:\\git\\repro\\consoletest\\consoletest.csproj", + "packagesPath": "C:\\Users\\username\\.nuget\\packages\\", + "outputPath": "C:\\git\\repro\\consoletest\\obj\\", + "projectStyle": "PackageReference", + "fallbackFolders": [], + "configFilePaths": [ + "C:\\Users\\username\\AppData\\Roaming\\NuGet\\NuGet.Config" + ], + "originalTargetFrameworks": [ + "netcoreapp1.0" + ], + "sources": { + "https://api.nuget.org/v3/index.json": {} + }, + "frameworks": { + "netcoreapp1.0": { + "targetAlias": "netcoreapp1.0", + "projectReferences": {} + } + }, + "warningProperties": { + "warnAsError": [ + "NU1605" + ] + } + }, + "frameworks": { + "netcoreapp1.0": { + "targetAlias": "netcoreapp1.0", + "dependencies": { + "Microsoft.NETCore.App": { + "target": "Package", + "version": "[1.0.5, )", + "autoReferenced": true + } + }, + "runtimeIdentifierGraphPath": "C:\\git\\dotnet-sdk\\artifacts\\bin\\redist\\Debug\\dotnet\\sdk\\5.0.100-dev\\RuntimeIdentifierGraph.json" + } + } } } diff --git a/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/LockFiles/dependencies.withgraphs.project.lock.json b/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/LockFiles/dependencies.withgraphs.project.lock.json index 6997e9b6f869..db171875261e 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/LockFiles/dependencies.withgraphs.project.lock.json +++ b/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/LockFiles/dependencies.withgraphs.project.lock.json @@ -1,5 +1,5 @@ { - "version": 2, + "version": 3, "targets": { ".NETStandard,Version=v1.6": { "Microsoft.CSharp/4.0.1": { @@ -2824,9 +2824,52 @@ "Newtonsoft.Json >= 9.0.1" ] }, - "tools": {}, - "projectFileToolGroups": {}, "packageFolders": { - "C:\\Users\\eerhardt\\.nuget\\packages\\": {} + "C:\\.nuget\\packages\\": {} + }, + "project": { + "version": "1.0.0", + "restore": { + "projectUniqueName": "C:\\git\\repro\\consoletest\\consoletest.csproj", + "projectName": "consoletest", + "projectPath": "C:\\git\\repro\\consoletest\\consoletest.csproj", + "packagesPath": "C:\\Users\\username\\.nuget\\packages\\", + "outputPath": "C:\\git\\repro\\consoletest\\obj\\", + "projectStyle": "PackageReference", + "fallbackFolders": [], + "configFilePaths": [ + "C:\\Users\\username\\AppData\\Roaming\\NuGet\\NuGet.Config" + ], + "originalTargetFrameworks": [ + "netstandard1.6" + ], + "sources": { + "https://api.nuget.org/v3/index.json": {} + }, + "frameworks": { + "netstandard1.6": { + "targetAlias": "netstandard1.6", + "projectReferences": {} + } + }, + "warningProperties": { + "warnAsError": [ + "NU1605" + ] + } + }, + "frameworks": { + "netstandard1.6": { + "targetAlias": "netstandard1.6", + "dependencies": { + "Microsoft.NETCore.App": { + "target": "Package", + "version": "[1.0.5, )", + "autoReferenced": true + } + }, + "runtimeIdentifierGraphPath": "C:\\git\\dotnet-sdk\\artifacts\\bin\\redist\\Debug\\dotnet\\sdk\\5.0.100-dev\\RuntimeIdentifierGraph.json" + } + } } -} \ No newline at end of file +} diff --git a/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/LockFiles/dotnet.new.project.lock.json b/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/LockFiles/dotnet.new.project.lock.json index 0e2596ed077a..9c1b429f6323 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/LockFiles/dotnet.new.project.lock.json +++ b/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/LockFiles/dotnet.new.project.lock.json @@ -1,5 +1,5 @@ { - "version": 2, + "version": 3, "targets": { ".NETCoreApp,Version=v1.0": { "Libuv/1.9.0": { @@ -6592,9 +6592,52 @@ "Microsoft.NETCore.App >= 1.0.0" ] }, - "tools": {}, - "projectFileToolGroups": {}, "packageFolders": { "C:\\.nuget\\packages\\": {} + }, + "project": { + "version": "1.0.0", + "restore": { + "projectUniqueName": "C:\\git\\repro\\consoletest\\consoletest.csproj", + "projectName": "consoletest", + "projectPath": "C:\\git\\repro\\consoletest\\consoletest.csproj", + "packagesPath": "C:\\Users\\username\\.nuget\\packages\\", + "outputPath": "C:\\git\\repro\\consoletest\\obj\\", + "projectStyle": "PackageReference", + "fallbackFolders": [], + "configFilePaths": [ + "C:\\Users\\username\\AppData\\Roaming\\NuGet\\NuGet.Config" + ], + "originalTargetFrameworks": [ + "netcoreapp1.0" + ], + "sources": { + "https://api.nuget.org/v3/index.json": {} + }, + "frameworks": { + "netcoreapp1.0": { + "targetAlias": "netcoreapp1.0", + "projectReferences": {} + } + }, + "warningProperties": { + "warnAsError": [ + "NU1605" + ] + } + }, + "frameworks": { + "netcoreapp1.0": { + "targetAlias": "netcoreapp1.0", + "dependencies": { + "Microsoft.NETCore.App": { + "target": "Package", + "version": "[1.0.5, )", + "autoReferenced": true + } + }, + "runtimeIdentifierGraphPath": "C:\\git\\dotnet-sdk\\artifacts\\bin\\redist\\Debug\\dotnet\\sdk\\5.0.100-dev\\RuntimeIdentifierGraph.json" + } + } } } \ No newline at end of file diff --git a/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/LockFiles/simple.dependencies.project.lock.json b/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/LockFiles/simple.dependencies.project.lock.json index 029c873843a4..1209d9b9be9b 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/LockFiles/simple.dependencies.project.lock.json +++ b/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/LockFiles/simple.dependencies.project.lock.json @@ -1,6 +1,6 @@ { "locked": false, - "version": 2, + "version": 3, "targets": { ".NETCoreApp,Version=v1.0": { "Libuv/1.9.0": { @@ -6791,6 +6791,52 @@ "System.Collections.NonGeneric >= 4.0.1" ] }, - "tools": {}, - "projectFileToolGroups": {} + "packageFolders": { + "C:\\.nuget\\packages\\": {} + }, + "project": { + "version": "1.0.0", + "restore": { + "projectUniqueName": "C:\\git\\repro\\consoletest\\consoletest.csproj", + "projectName": "consoletest", + "projectPath": "C:\\git\\repro\\consoletest\\consoletest.csproj", + "packagesPath": "C:\\Users\\username\\.nuget\\packages\\", + "outputPath": "C:\\git\\repro\\consoletest\\obj\\", + "projectStyle": "PackageReference", + "fallbackFolders": [], + "configFilePaths": [ + "C:\\Users\\username\\AppData\\Roaming\\NuGet\\NuGet.Config" + ], + "originalTargetFrameworks": [ + "netcoreapp1.0" + ], + "sources": { + "https://api.nuget.org/v3/index.json": {} + }, + "frameworks": { + "netcoreapp1.0": { + "targetAlias": "netcoreapp1.0", + "projectReferences": {} + } + }, + "warningProperties": { + "warnAsError": [ + "NU1605" + ] + } + }, + "frameworks": { + "netcoreapp1.0": { + "targetAlias": "netcoreapp1.0", + "dependencies": { + "Microsoft.NETCore.App": { + "target": "Package", + "version": "[1.0.5, )", + "autoReferenced": true + } + }, + "runtimeIdentifierGraphPath": "C:\\git\\dotnet-sdk\\artifacts\\bin\\redist\\Debug\\dotnet\\sdk\\5.0.100-dev\\RuntimeIdentifierGraph.json" + } + } + } } \ No newline at end of file diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/CheckForTargetInAssetsFile.cs b/src/Tasks/Microsoft.NET.Build.Tasks/CheckForTargetInAssetsFile.cs index bd3812343d8d..9ea8e9728fd3 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/CheckForTargetInAssetsFile.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks/CheckForTargetInAssetsFile.cs @@ -14,7 +14,7 @@ public class CheckForTargetInAssetsFile : TaskBase public string AssetsFilePath { get; set; } [Required] - public string TargetFrameworkMoniker { get; set; } + public string TargetFramework { get; set; } public string RuntimeIdentifier { get; set; } @@ -23,9 +23,7 @@ protected override void ExecuteCore() { LockFile lockFile = new LockFileCache(this).GetLockFile(AssetsFilePath); - var nugetFramework = NuGetUtils.ParseFrameworkName(TargetFrameworkMoniker); - - lockFile.GetTargetAndThrowIfNotFound(nugetFramework, RuntimeIdentifier); + lockFile.GetTargetAndThrowIfNotFound(TargetFramework, RuntimeIdentifier); } } } diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/FilterResolvedFiles.cs b/src/Tasks/Microsoft.NET.Build.Tasks/FilterResolvedFiles.cs index a0d670cabd25..8faf44755651 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/FilterResolvedFiles.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks/FilterResolvedFiles.cs @@ -30,8 +30,6 @@ public class FilterResolvedFiles : TaskBase [Required] public string TargetFramework { get; set; } - public string TargetPlatformMoniker { get; set; } - public string RuntimeIdentifier { get; set; } public string PlatformLibraryName { get; set; } @@ -58,7 +56,7 @@ protected override void ExecuteCore() LockFile lockFile = lockFileCache.GetLockFile(AssetsFilePath); ProjectContext projectContext = lockFile.CreateProjectContext( - NuGetTargetFrameworkUtils.GetTargetFramework(TargetFramework, TargetPlatformMoniker), + TargetFramework, RuntimeIdentifier, PlatformLibraryName, runtimeFrameworks: null, diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/GenerateDepsFile.cs b/src/Tasks/Microsoft.NET.Build.Tasks/GenerateDepsFile.cs index f259fd5fd97b..26915d54c304 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/GenerateDepsFile.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks/GenerateDepsFile.cs @@ -32,8 +32,6 @@ public class GenerateDepsFile : TaskBase [Required] public string TargetFramework { get; set; } - public string TargetPlatformMoniker { get; set; } - public string RuntimeIdentifier { get; set; } public string PlatformLibraryName { get; set; } @@ -136,7 +134,7 @@ private void WriteDepsFile(string depsFilePath) { LockFile lockFile = new LockFileCache(this).GetLockFile(AssetsFilePath); projectContext = lockFile.CreateProjectContext( - NuGetTargetFrameworkUtils.GetTargetFramework(TargetFramework, TargetPlatformMoniker), + TargetFramework, RuntimeIdentifier, PlatformLibraryName, RuntimeFrameworks, diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/GenerateRuntimeConfigurationFiles.cs b/src/Tasks/Microsoft.NET.Build.Tasks/GenerateRuntimeConfigurationFiles.cs index a85a61e0c944..11f12fd44aef 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/GenerateRuntimeConfigurationFiles.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks/GenerateRuntimeConfigurationFiles.cs @@ -24,9 +24,10 @@ public class GenerateRuntimeConfigurationFiles : TaskBase public string AssetsFilePath { get; set; } [Required] - public string TargetFrameworkMoniker { get; set; } + public string TargetFramework { get; set; } - public string TargetPlatformMoniker { get; set; } + [Required] + public string TargetFrameworkMoniker { get; set; } [Required] public string RuntimeConfigPath { get; set; } @@ -126,7 +127,7 @@ protected override void ExecuteCore() LockFile lockFile = new LockFileCache(this).GetLockFile(AssetsFilePath); ProjectContext projectContext = lockFile.CreateProjectContext( - NuGetTargetFrameworkUtils.GetTargetFramework(TargetFrameworkMoniker, TargetPlatformMoniker), + TargetFramework, RuntimeIdentifier, PlatformLibraryName, RuntimeFrameworks, diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/LockFileExtensions.cs b/src/Tasks/Microsoft.NET.Build.Tasks/LockFileExtensions.cs index a95beba36800..d66082e79310 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/LockFileExtensions.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks/LockFileExtensions.cs @@ -13,13 +13,13 @@ namespace Microsoft.NET.Build.Tasks { internal static class LockFileExtensions { - public static LockFileTarget GetTargetAndThrowIfNotFound(this LockFile lockFile, NuGetFramework framework, string runtime) + public static LockFileTarget GetTargetAndThrowIfNotFound(this LockFile lockFile, string frameworkAlias, string runtime) { - LockFileTarget lockFileTarget = lockFile.GetTarget(framework, runtime); + LockFileTarget lockFileTarget = lockFile.GetTarget(frameworkAlias, runtime); if (lockFileTarget == null) { - string frameworkString = framework.DotNetFrameworkName; + string frameworkString = frameworkAlias; string targetMoniker = string.IsNullOrEmpty(runtime) ? frameworkString : $"{frameworkString}/{runtime}"; @@ -27,11 +27,11 @@ public static LockFileTarget GetTargetAndThrowIfNotFound(this LockFile lockFile, string message; if (string.IsNullOrEmpty(runtime)) { - message = string.Format(Strings.AssetsFileMissingTarget, lockFile.Path, targetMoniker, framework.GetShortFolderName()); + message = string.Format(Strings.AssetsFileMissingTarget, lockFile.Path, targetMoniker, frameworkString); } else { - message = string.Format(Strings.AssetsFileMissingRuntimeIdentifier, lockFile.Path, targetMoniker, framework.GetShortFolderName(), runtime); + message = string.Format(Strings.AssetsFileMissingRuntimeIdentifier, lockFile.Path, targetMoniker, frameworkString, runtime); } throw new BuildErrorException(message); @@ -40,9 +40,19 @@ public static LockFileTarget GetTargetAndThrowIfNotFound(this LockFile lockFile, return lockFileTarget; } + public static string GetLockFileTargetAlias(this LockFile lockFile, LockFileTarget lockFileTarget) + { + var frameworkAlias = lockFile.PackageSpec.TargetFrameworks.FirstOrDefault(tfi => tfi.FrameworkName == lockFileTarget.TargetFramework)?.TargetAlias; + if (frameworkAlias == null) + { + throw new ArgumentException("Could not find TargetFramework alias in lock file for " + lockFileTarget.TargetFramework); + } + return frameworkAlias; + } + public static ProjectContext CreateProjectContext( this LockFile lockFile, - NuGetFramework framework, + string frameworkAlias, string runtime, // Trimmed from publish output, and if there are no runtimeFrameworks, written to runtimeconfig.json string platformLibraryName, @@ -54,12 +64,12 @@ public static ProjectContext CreateProjectContext( { throw new ArgumentNullException(nameof(lockFile)); } - if (framework == null) + if (frameworkAlias == null) { - throw new ArgumentNullException(nameof(framework)); + throw new ArgumentNullException(nameof(frameworkAlias)); } - var lockFileTarget = lockFile.GetTargetAndThrowIfNotFound(framework, runtime); + var lockFileTarget = lockFile.GetTargetAndThrowIfNotFound(frameworkAlias, runtime); LockFileTargetLibrary platformLibrary = lockFileTarget.GetLibrary(platformLibraryName); bool isFrameworkDependent = IsFrameworkDependent(runtimeFrameworks, isSelfContained, lockFileTarget.RuntimeIdentifier, platformLibrary != null); diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/PreprocessPackageDependenciesDesignTime.cs b/src/Tasks/Microsoft.NET.Build.Tasks/PreprocessPackageDependenciesDesignTime.cs index bacde6eb4335..10f763fbdb7b 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/PreprocessPackageDependenciesDesignTime.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks/PreprocessPackageDependenciesDesignTime.cs @@ -50,11 +50,12 @@ public class PreprocessPackageDependenciesDesignTime : TaskBase public string DefaultImplicitPackages { get; set; } /// - /// Eg: ".NETCoreApp,Version=v5.0". + /// The TargetFramework, which may be an alias + /// Eg: "netcoreapp3.1", "net5.0-windows", etc. /// Only packages targeting this framework will be returned. /// [Required] - public string TargetFrameworkMoniker { get; set; } + public string TargetFramework { get; set; } [Output] public ITaskItem[] PackageDependenciesDesignTime { get; private set; } @@ -82,7 +83,7 @@ protected override void ExecuteCore() var target = dependency.GetMetadata(MetadataKeys.ParentTarget); - if (!StringComparer.OrdinalIgnoreCase.Equals(target, TargetFrameworkMoniker)) + if (!StringComparer.OrdinalIgnoreCase.Equals(target, TargetFramework)) { // skip dependencies for other targets continue; diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/ProjectContext.cs b/src/Tasks/Microsoft.NET.Build.Tasks/ProjectContext.cs index a53bc4fa29d0..57692b0e4678 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/ProjectContext.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks/ProjectContext.cs @@ -79,7 +79,8 @@ public ProjectContext(LockFile lockFile, LockFileTarget lockFileTarget, } else { - CompilationLockFileTarget = lockFile.GetTargetAndThrowIfNotFound(lockFileTarget.TargetFramework, null); + var frameworkAlias = lockFile.GetLockFileTargetAlias(lockFileTarget); + CompilationLockFileTarget = lockFile.GetTargetAndThrowIfNotFound(frameworkAlias, null); } PlatformLibrary = platformLibrary; @@ -189,10 +190,12 @@ static public IEnumerable GetTopLevelDependencies(LockFile lockFile, Loc Dictionary libraryLookup = lockFileTarget.Libraries.ToDictionary(l => l.Name, StringComparer.OrdinalIgnoreCase); + string lockFileTargetFramework = lockFileTarget.Name.Split('/')[0]; + return lockFile .ProjectFileDependencyGroups .Where(dg => dg.FrameworkName == string.Empty || - dg.FrameworkName == lockFileTarget.TargetFramework.DotNetFrameworkName) + dg.FrameworkName == lockFileTargetFramework) .SelectMany(g => g.Dependencies) .Select(projectFileDependency => { diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/ResolveCopyLocalAssets.cs b/src/Tasks/Microsoft.NET.Build.Tasks/ResolveCopyLocalAssets.cs index 10d99b646513..dbefcc815dbc 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/ResolveCopyLocalAssets.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks/ResolveCopyLocalAssets.cs @@ -23,8 +23,6 @@ public class ResolveCopyLocalAssets : TaskBase [Required] public string TargetFramework { get; set; } - public string TargetPlatformMoniker { get; set; } - public string RuntimeIdentifier { get; set; } public string PlatformLibraryName { get; set; } @@ -60,7 +58,7 @@ protected override void ExecuteCore() } ProjectContext projectContext = lockFile.CreateProjectContext( - NuGetTargetFrameworkUtils.GetTargetFramework(TargetFramework, TargetPlatformMoniker), + TargetFramework, RuntimeIdentifier, PlatformLibraryName, RuntimeFrameworks, diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/ResolvePackageAssets.cs b/src/Tasks/Microsoft.NET.Build.Tasks/ResolvePackageAssets.cs index dc98a77347b5..d65b3a470ce8 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/ResolvePackageAssets.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks/ResolvePackageAssets.cs @@ -45,15 +45,10 @@ public sealed class ResolvePackageAssets : TaskBase public string ProjectPath { get; set; } /// - /// TFM to use for compile-time assets. + /// TargetFramework to use for compile-time assets. /// [Required] - public string TargetFrameworkMoniker { get; set; } - - /// - /// TPM to use for compile-time assets. - /// - public string TargetPlatformMoniker { get; set; } + public string TargetFramework { get; set; } /// /// RID to use for runtime assets (may be empty) @@ -438,8 +433,7 @@ internal byte[] HashSettings() writer.Write(r.ItemSpec ?? ""); } } - writer.Write(TargetFrameworkMoniker); - writer.Write(TargetPlatformMoniker ?? ""); + writer.Write(TargetFramework); writer.Write(VerifyMatchingImplicitPackageVersion); } @@ -640,7 +634,7 @@ private sealed class CacheWriter : IDisposable private HashSet _copyLocalPackageExclusions; private HashSet _publishPackageExclusions; private Placeholder _metadataStringTablePosition; - private NuGetFramework _targetFramework; + private string _targetFramework; private int _itemCount; public bool CanWriteToCacheFile { get; set; } @@ -651,7 +645,7 @@ private sealed class CacheWriter : IDisposable public CacheWriter(ResolvePackageAssets task) { - _targetFramework = NuGetTargetFrameworkUtils.GetTargetFramework(task.TargetFrameworkMoniker, task.TargetPlatformMoniker); + _targetFramework = task.TargetFramework; _task = task; _lockFile = new LockFileCache(task).GetLockFile(task.ProjectAssetsFile); @@ -1092,13 +1086,25 @@ private void WriteApphostsForShimRuntimeIdentifiers() /// private bool CanResolveApphostFromFrameworkReference() { - if (_targetFramework.Version.Major >= 3 - && _targetFramework.Framework.Equals(".NETCoreApp", StringComparison.OrdinalIgnoreCase)) + if (!CanWriteToCacheFile) { + // If we can't write to the cache file, it's because this is a design-time build where the + // TargetFramework doesn't match what's in the assets file. So don't try looking up the + // TargetFramework in the assets file. return false; } + else + { + var targetFramework = _lockFile.GetTarget(_targetFramework, null).TargetFramework; - return true; + if (targetFramework.Version.Major >= 3 + && targetFramework.Framework.Equals(".NETCoreApp", StringComparison.OrdinalIgnoreCase)) + { + return false; + } + + return true; + } } private void WritePackageFolders() @@ -1481,27 +1487,4 @@ private Tuple FindApphostInRuntimeTarget(string a } } } - - internal static class NuGetTargetFrameworkUtils - { - public static NuGetFramework GetTargetFramework(string targetFrameworkMoniker, string targetPlatformMoniker) - { - var targetFramework = NuGetUtils.ParseFrameworkName(targetFrameworkMoniker); - if (targetPlatformMoniker != null && !targetPlatformMoniker.Equals(string.Empty)) - { - try - { - var targetPlatform = NuGetUtils.ParseFrameworkName(targetPlatformMoniker); - var constructedFramework = new NuGetFramework(targetFramework.Framework, targetFramework.Version, targetPlatform.Framework, targetPlatform.Version); - - return constructedFramework; - } - catch - { - return targetFramework; - } - } - return targetFramework; - } - } } diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/ResolvePackageDependencies.cs b/src/Tasks/Microsoft.NET.Build.Tasks/ResolvePackageDependencies.cs index 0238f434bf9d..6cb69accda28 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/ResolvePackageDependencies.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks/ResolvePackageDependencies.cs @@ -142,11 +142,28 @@ internal ResolvePackageDependencies(LockFile lockFile, IPackageResolver packageR private LockFile LockFile => _lockFile ??= new LockFileCache(this).GetLockFile(ProjectAssetsFile); + private Dictionary _targetNameToAliasMap; + /// /// Raise Nuget LockFile representation to MSBuild items /// protected override void ExecuteCore() { + var targetFrameworkToAliasMap = LockFile.PackageSpec.TargetFrameworks.ToDictionary(tf => tf.FrameworkName.DotNetFrameworkName, tf => tf.TargetAlias); + + _targetNameToAliasMap = LockFile.Targets.ToDictionary(t => t.Name, t => + { + var alias = targetFrameworkToAliasMap[t.TargetFramework.DotNetFrameworkName]; + if (string.IsNullOrEmpty(t.RuntimeIdentifier)) + { + return alias; + } + else + { + return alias + "/" + t.RuntimeIdentifier; + } + }); + ReadProjectFileDependencies(); RaiseLockFileTargets(); GetPackageAndFileDefinitions(); @@ -211,8 +228,10 @@ private void GetPackageAndFileDefinitions() foreach (var target in parentTargets) { + string frameworkAlias = _targetNameToAliasMap[target.Name]; + var fileDepsItem = new TaskItem(fileKey); - fileDepsItem.SetMetadata(MetadataKeys.ParentTarget, target.Name); // Foreign Key + fileDepsItem.SetMetadata(MetadataKeys.ParentTarget, frameworkAlias); // Foreign Key fileDepsItem.SetMetadata(MetadataKeys.ParentPackage, packageId); // Foreign Key _fileDependencies.Add(fileDepsItem); @@ -286,8 +305,10 @@ private void GetPackageAndFileDependencies(LockFileTarget target) if (_projectFileDependencies.Contains(package.Name)) { + string frameworkAlias = _targetNameToAliasMap[target.Name]; + TaskItem item = new TaskItem(packageId); - item.SetMetadata(MetadataKeys.ParentTarget, target.Name); // Foreign Key + item.SetMetadata(MetadataKeys.ParentTarget, frameworkAlias); // Foreign Key item.SetMetadata(MetadataKeys.ParentPackage, string.Empty); // Foreign Key _packageDependencies.Add(item); @@ -311,6 +332,7 @@ private void GetPackageDependencies( HashSet transitiveProjectRefs) { string packageId = $"{package.Name}/{package.Version.ToNormalizedString()}"; + string frameworkAlias = _targetNameToAliasMap[targetName]; foreach (var deps in package.Dependencies) { if (!resolvedPackageVersions.TryGetValue(deps.Id, out string version)) @@ -321,7 +343,7 @@ private void GetPackageDependencies( string depsName = $"{deps.Id}/{version}"; TaskItem item = new TaskItem(depsName); - item.SetMetadata(MetadataKeys.ParentTarget, targetName); // Foreign Key + item.SetMetadata(MetadataKeys.ParentTarget, frameworkAlias); // Foreign Key item.SetMetadata(MetadataKeys.ParentPackage, packageId); // Foreign Key if (transitiveProjectRefs.Contains(deps.Id)) @@ -336,6 +358,7 @@ private void GetPackageDependencies( private void GetFileDependencies(LockFileTargetLibrary package, string targetName) { string packageId = $"{package.Name}/{package.Version.ToNormalizedString()}"; + string frameworkAlias = _targetNameToAliasMap[targetName]; // for each type of file group foreach (var fileGroup in (FileGroup[])Enum.GetValues(typeof(FileGroup))) @@ -354,7 +377,7 @@ private void GetFileDependencies(LockFileTargetLibrary package, string targetNam var fileKey = $"{packageId}/{filePath}"; var item = new TaskItem(fileKey); item.SetMetadata(MetadataKeys.FileGroup, fileGroup.ToString()); - item.SetMetadata(MetadataKeys.ParentTarget, targetName); // Foreign Key + item.SetMetadata(MetadataKeys.ParentTarget, frameworkAlias); // Foreign Key item.SetMetadata(MetadataKeys.ParentPackage, packageId); // Foreign Key if (fileGroup == FileGroup.FrameworkAssembly) diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.ComposeStore.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.ComposeStore.targets index 27c56563810d..bca1187fe9bb 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.ComposeStore.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.ComposeStore.targets @@ -420,8 +420,7 @@ Copyright (c) .NET Foundation. All rights reserved. diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.CrossGen.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.CrossGen.targets index f2553e2f6d2e..fdc73e3e8943 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.CrossGen.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.CrossGen.targets @@ -279,7 +279,6 @@ Copyright (c) .NET Foundation. All rights reserved. @@ -104,8 +103,8 @@ Copyright (c) .NET Foundation. All rights reserved. PlatformLibraryName="$(MicrosoftNETPlatformLibrary)" RuntimeConfigPath="$(_DesignerRuntimeConfigFilePath)" RuntimeFrameworks="@(RuntimeFramework)" + TargetFramework="$(TargetFramework)" TargetFrameworkMoniker="$(TargetFrameworkMoniker)" - TargetPlatformMoniker="$(TargetPlatformMoniker)" UserRuntimeConfig="$(UserRuntimeConfig)" WriteAdditionalProbingPathsToMainConfig="true" /> diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets index 1546f9b08255..8c266b06c155 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets @@ -609,8 +609,7 @@ Copyright (c) .NET Foundation. All rights reserved. 9999 + + Condition="'$(Language)' == 'C#' Or '$(Language)' == 'VB'" /> diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.FSharp.props b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.FSharp.props index 1f603b2a18c6..4412b6594487 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.FSharp.props +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.FSharp.props @@ -28,4 +28,8 @@ Copyright (c) .NET Foundation. All rights reserved. + + false + + diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets index 6952e5b3ddd7..eca1518e417f 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets @@ -195,8 +195,7 @@ Copyright (c) .NET Foundation. All rights reserved. $([MSBuild]::GetTargetFrameworkIdentifier('$(TargetFramework)')) - v$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)', 3)) - <_TargetFrameworkVersionLength Condition="$(TargetFrameworkVersion.EndsWith('.0'))" >$([MSBuild]::Subtract($(TargetFrameworkVersion.Length), 2)) - $(TargetFrameworkVersion.Substring(0, $(_TargetFrameworkVersionLength))) + v$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)', 2)) - - $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) - $([MSBuild]::GetTargetPlatformVersion('$(TargetFramework)', 3)) - - <_TargetPlatformVersionLength Condition="$(TargetPlatformVersion.EndsWith('.0'))" >$([MSBuild]::Subtract($(TargetPlatformVersion.Length), 2)) - $(TargetPlatformVersion.Substring(0, $(_TargetPlatformVersionLength))) + + $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) + $([MSBuild]::GetTargetPlatformVersion('$(TargetFramework)', 4)) + $([MSBuild]::GetTargetPlatformVersion('$(TargetFramework)', 2)) + Windows @@ -161,7 +158,8 @@ Copyright (c) .NET Foundation. All rights reserved. /> - + + <_EnableDefaultWindowsPlatform>false false @@ -198,9 +196,10 @@ Copyright (c) .NET Foundation. All rights reserved. FormatArguments="$(SupportedOSPlatform);$(TargetPlatformVersion)"/> + + Condition="'$(TargetPlatformVersion)' != '' and '$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), 5.0)) and '$(Language)' != 'C++'"> <_ValidTargetPlatformVersion Include="@(SdkSupportedTargetPlatform)" Condition="'@(SdkSupportedTargetPlatform)' != '' and $([MSBuild]::VersionEquals(%(Identity), $(TargetPlatformVersion)))" /> @@ -213,7 +212,7 @@ Copyright (c) .NET Foundation. All rights reserved. + Condition="'$(TargetPlatformVersion)' != '' and '$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), 5.0)) and '$(Language)' != 'C++'"> true <_ValidTargetPlatformVersions Condition="'@(SdkSupportedTargetPlatform)' != ''" >@(SdkSupportedTargetPlatform, '%0a') diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Windows.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Windows.targets index b86bf20d17e2..1d14866ca6d8 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Windows.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Windows.targets @@ -11,12 +11,15 @@ Copyright (c) .NET Foundation. All rights reserved. --> + + + and $([MSBuild]::VersionGreaterThanOrEquals($(TargetPlatformVersion), '10.0')) + and '$(Language)' != 'C++'"> <_IncludeWindowsSDKRefFrameworkReferences>true diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.WindowsSdkSupportedTargetPlatforms.props b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.WindowsSdkSupportedTargetPlatforms.props index b27e16caff12..5041005639a4 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.WindowsSdkSupportedTargetPlatforms.props +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.WindowsSdkSupportedTargetPlatforms.props @@ -13,9 +13,9 @@ Copyright (c) .NET Foundation. All rights reserved. - - - + + + diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.PackageDependencyResolution.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.PackageDependencyResolution.targets index d21b43883550..4da8a02c7ad9 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.PackageDependencyResolution.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.PackageDependencyResolution.targets @@ -179,7 +179,7 @@ Copyright (c) .NET Foundation. All rights reserved. compile errors. --> @@ -244,8 +244,7 @@ Copyright (c) .NET Foundation. All rights reserved. ProjectPath="$(MSBuildProjectFullPath)" ProjectLanguage="$(Language)" EmitAssetsLogMessages="$(EmitAssetsLogMessages)" - TargetFrameworkMoniker="$(NuGetTargetMoniker)" - TargetPlatformMoniker="$(TargetPlatformMoniker)" + TargetFramework="$(TargetFramework)" RuntimeIdentifier="$(RuntimeIdentifier)" PlatformLibraryName="$(MicrosoftNETPlatformLibrary)" RuntimeFrameworks="@(RuntimeFramework)" @@ -314,7 +313,7 @@ Copyright (c) .NET Foundation. All rights reserved. PackageDefinitions="@(PackageDefinitions)" PackageDependencies="@(PackageDependencies)" DefaultImplicitPackages="$(DefaultImplicitPackages)" - TargetFrameworkMoniker="$(NuGetTargetMoniker)"> + TargetFramework="$(TargetFramework)"> diff --git a/src/Tests/Microsoft.DotNet.MSBuildSdkResolver.Tests/GivenAnMSBuildSdkResolver.cs b/src/Tests/Microsoft.DotNet.MSBuildSdkResolver.Tests/GivenAnMSBuildSdkResolver.cs index a91e9c877c5f..3ef689e59807 100644 --- a/src/Tests/Microsoft.DotNet.MSBuildSdkResolver.Tests/GivenAnMSBuildSdkResolver.cs +++ b/src/Tests/Microsoft.DotNet.MSBuildSdkResolver.Tests/GivenAnMSBuildSdkResolver.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +extern alias sdkResolver; using FluentAssertions; using Microsoft.Build.Framework; using Microsoft.DotNet.MSBuildSdkResolver; @@ -496,7 +497,7 @@ public void GivenTemplateLocatorItCanResolveSdkVersion() environment.CreateMuxerAndAddToPath(ProgramFiles.X64); var resolver = new TemplateLocator.TemplateLocator(environment.GetEnvironmentVariable, - new VSSettings(environment.VSSettingsFile?.FullName, environment.DisallowPrereleaseByDefault)); + new sdkResolver::Microsoft.DotNet.DotNetSdkResolver.VSSettings(environment.VSSettingsFile?.FullName, environment.DisallowPrereleaseByDefault)); resolver.TryGetDotnetSdkVersionUsedInVs("15.8", out var version).Should().BeTrue(); version.Should().Be(sdkVersion); diff --git a/src/Tests/Microsoft.DotNet.MSBuildSdkResolver.Tests/Microsoft.DotNet.MSBuildSdkResolver.Tests.csproj b/src/Tests/Microsoft.DotNet.MSBuildSdkResolver.Tests/Microsoft.DotNet.MSBuildSdkResolver.Tests.csproj index 5938d24d4894..f7b7e7d5f00d 100644 --- a/src/Tests/Microsoft.DotNet.MSBuildSdkResolver.Tests/Microsoft.DotNet.MSBuildSdkResolver.Tests.csproj +++ b/src/Tests/Microsoft.DotNet.MSBuildSdkResolver.Tests/Microsoft.DotNet.MSBuildSdkResolver.Tests.csproj @@ -13,7 +13,11 @@ - + + + + sdkResolver + diff --git a/src/Tests/Microsoft.NET.Build.Tests/DesignTimeBuildTests.cs b/src/Tests/Microsoft.NET.Build.Tests/DesignTimeBuildTests.cs index b2d353b960c7..263455439cb6 100644 --- a/src/Tests/Microsoft.NET.Build.Tests/DesignTimeBuildTests.cs +++ b/src/Tests/Microsoft.NET.Build.Tests/DesignTimeBuildTests.cs @@ -4,6 +4,7 @@ using System.Runtime.CompilerServices; using System.Text; using System.Xml.Linq; +using FluentAssertions; using Microsoft.NET.TestFramework; using Microsoft.NET.TestFramework.Assertions; using Microsoft.NET.TestFramework.Commands; @@ -79,6 +80,37 @@ public void DesignTimeBuildSucceedsAfterRuntimeIdentifierIsChanged() }); } + [Theory] + [InlineData("netcoreapp3.0")] + [InlineData("net5.0")] + [InlineData("net5.0-windows")] + [InlineData("net5.0-windows7.0")] + public void DesignTimePackageDependenciesAreResolved(string targetFramework) + { + var testProject = new TestProject() + { + Name = "DesignTimePackageDependencies", + TargetFrameworks = targetFramework, + IsSdkProject = true + }; + + testProject.PackageReferences.Add(new TestPackageReference("Newtonsoft.Json", "12.0.2", privateAssets: "All")); + testProject.PackageReferences.Add(new TestPackageReference("Humanizer", "2.6.2")); + + var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: targetFramework); + + var getValuesCommand = new GetValuesCommand(testAsset, "_PackageDependenciesDesignTime", GetValuesCommand.ValueType.Item); + getValuesCommand.DependsOnTargets = "ResolvePackageDependenciesDesignTime"; + + getValuesCommand.Execute() + .Should() + .Pass(); + + getValuesCommand.GetValues() + .Should() + .BeEquivalentTo("Newtonsoft.Json/12.0.2", "Humanizer/2.6.2"); + } + private void TestDesignTimeBuildAfterChange(Action projectChange, [CallerMemberName] string callingMethod = "") { var designTimeArgs = GetDesignTimeMSBuildArgs(); @@ -103,7 +135,7 @@ private void TestDesignTimeBuildAfterChange(Action projectChange, [Ca // Use a test-specific packages folder testProject.AdditionalProperties["RestorePackagesPath"] = @"$(MSBuildProjectDirectory)\packages"; - var testAsset = _testAssetsManager.CreateTestProject(testProject) + var testAsset = _testAssetsManager.CreateTestProject(testProject, callingMethod: callingMethod) .WithProjectChanges(p => { var ns = p.Root.Name.Namespace; diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildADesktopExeWithFSharp.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildADesktopExeWithFSharp.cs index 3b46693ac0e3..970d67bb4edc 100644 --- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildADesktopExeWithFSharp.cs +++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildADesktopExeWithFSharp.cs @@ -57,5 +57,21 @@ public void It_builds_a_simple_desktop_app() "System.ValueTuple.dll", }); } + + // https://github.com/dotnet/sdk/issues/12560 + [CoreMSBuildAndWindowsOnlyFact] + public void It_builds_a_simple_net50_app() + { + var testAsset = _testAssetsManager + .CopyTestAsset("HelloWorldFS") + .WithSource() + .WithTargetFramework("net5.0"); + + var buildCommand = new BuildCommand(testAsset); + buildCommand + .Execute() + .Should() + .Pass(); + } } } diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibrary.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibrary.cs index 0a63fa9c611f..7023057847b6 100644 --- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibrary.cs +++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibrary.cs @@ -454,7 +454,7 @@ public void It_implicitly_defines_compilation_constants_for_the_target_platform( [Theory] [InlineData(new[] { "1.0", "1.1" }, "ios", "1.1", new[] { "IOS", "IOS1_1", "IOS1_0" })] [InlineData(new[] { "11.11", "12.12", "13.13" }, "android", "12.12", new[] { "ANDROID", "ANDROID11_11", "ANDROID12_12" })] - [InlineData(new string[] { /* Use the built in SdkSupportedTargetPlatform items */}, "windows", "10.0.19041", new[] { "WINDOWS", "WINDOWS7_0", "WINDOWS8_0", "WINDOWS10_0_17763", "WINDOWS10_0_18362", "WINDOWS10_0_19041" })] + [InlineData(new string[] { /* Use the built in SdkSupportedTargetPlatform items */}, "windows", "10.0.19041.0", new[] { "WINDOWS", "WINDOWS7_0", "WINDOWS8_0", "WINDOWS10_0_17763_0", "WINDOWS10_0_18362_0", "WINDOWS10_0_19041_0" })] public void It_implicitly_defines_compilation_constants_for_the_target_platform_with_backwards_compatibility(string[] sdkSupportedTargetPlatform, string targetPlatformIdentifier, string targetPlatformVersion, string[] expectedDefines) { var targetFramework = "net5.0"; diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAWindowsDesktopProject.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAWindowsDesktopProject.cs index ab364978b385..f2b1c304d1b9 100644 --- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAWindowsDesktopProject.cs +++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAWindowsDesktopProject.cs @@ -122,17 +122,22 @@ public void It_fails_if_windows_target_platform_version_is_invalid() .HaveStdOutContaining("NETSDK1140"); } - [WindowsOnlyFact] - public void It_succeeds_if_windows_target_platform_version_has_trailing_zeros() + [WindowsOnlyTheory] + [InlineData(true)] + [InlineData(false)] + public void It_succeeds_if_windows_target_platform_version_does_not_have_trailing_zeros(bool setInTargetframework) { var testProject = new TestProject() { Name = "ValidWindowsVersion", IsSdkProject = true, - TargetFrameworks = "net5.0" + TargetFrameworks = setInTargetframework ? "net5.0-windows10.0.18362" : "net5.0" }; - testProject.AdditionalProperties["TargetPlatformIdentifier"] = "Windows"; - testProject.AdditionalProperties["TargetPlatformVersion"] = "10.0.18362.0"; // We must set this manually because if we set it in the TFM we remove the trailing zeroes. + if (!setInTargetframework) + { + testProject.AdditionalProperties["TargetPlatformIdentifier"] = "Windows"; + testProject.AdditionalProperties["TargetPlatformVersion"] = "10.0.18362"; + } var testAsset = _testAssetsManager.CreateTestProject(testProject); var buildCommand = new BuildCommand(testAsset); @@ -144,7 +149,7 @@ public void It_succeeds_if_windows_target_platform_version_has_trailing_zeros() getValuesCommand.Execute() .Should() .Pass(); - getValuesCommand.GetValues().Should().BeEquivalentTo(new[] { "10.0.18362" }); + getValuesCommand.GetValues().Should().BeEquivalentTo(new[] { "10.0.18362.0" }); } [Fact] diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithoutTransitiveProjectRefs.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithoutTransitiveProjectRefs.cs index 6aa29dcfdffa..ed0202b029c9 100644 --- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithoutTransitiveProjectRefs.cs +++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithoutTransitiveProjectRefs.cs @@ -29,14 +29,14 @@ public void It_builds_the_project_successfully_when_RAR_finds_all_references() { BuildAppWithTransitiveDependenciesAndTransitiveCompileReference(new []{"/p:DisableTransitiveProjectReferences=true"}); } - - [Fact] + + [Fact(Skip = "https://github.com/dotnet/sdk/issues/13081")] public void It_builds_the_project_successfully_with_static_graph_and_isolation() { BuildAppWithTransitiveDependenciesAndTransitiveCompileReference(new []{"/graph"}); } - [Fact] + [Fact(Skip = "https://github.com/dotnet/sdk/issues/13081")] public void It_cleans_the_project_successfully_with_static_graph_and_isolation() { var (testAsset, outputDirectories) = BuildAppWithTransitiveDependenciesAndTransitiveCompileReference(new []{"/graph"}); diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildWithATargetPlatform.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildWithATargetPlatform.cs index a4144f548dab..33a7e20f0d54 100644 --- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildWithATargetPlatform.cs +++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildWithATargetPlatform.cs @@ -25,7 +25,7 @@ public GivenThatWeWantToBuildWithATargetPlatform(ITestOutputHelper log) : base(l [InlineData("net5.0-Windows7.0", ".NETCoreApp", "v5.0", "Windows", "7.0")] [InlineData("net5.0-WINDOWS7.0", ".NETCoreApp", "v5.0", "Windows", "7.0")] [InlineData("net5.0-windows", ".NETCoreApp", "v5.0", "Windows", "7.0")] - [InlineData("net5.0-windows10.0.19041", ".NETCoreApp", "v5.0", "Windows", "10.0.19041")] + [InlineData("net5.0-windows10.0.19041.0", ".NETCoreApp", "v5.0", "Windows", "10.0.19041.0")] public void It_defines_target_platform_from_target_framework(string targetFramework, string expectedTargetFrameworkIdentifier, string expectedTargetFrameworkVersion, string expectedTargetPlatformIdentifier, string expectedTargetPlatformVersion) { var testProj = new TestProject() @@ -63,6 +63,28 @@ public void It_defines_target_platform_from_target_framework(string targetFramew assertValue("TargetPlatformDisplayName", $"{expectedTargetPlatformIdentifier} {expectedTargetPlatformVersion}"); } + [WindowsOnlyRequiresMSBuildVersionFact("16.8.0.41402")] + public void It_defines_target_platform_from_target_framework_with_explicit_version() + { + var targetPlatformVersion = "10.0.19041.0"; + var targetFramework = "net5.0-windows"; + var testProj = new TestProject() + { + Name = "TargetPlatformTests", + IsSdkProject = true, + TargetFrameworks = targetFramework + }; + testProj.AdditionalProperties["TargetPlatformVersion"] = targetPlatformVersion; + var testAsset = _testAssetsManager.CreateTestProject(testProj); + + var getValuesCommand = new GetValuesCommand(Log, Path.Combine(testAsset.Path, testProj.Name), targetFramework, "TargetPlatformIdentifier"); + getValuesCommand + .Execute() + .Should() + .Pass(); + getValuesCommand.GetValues().ShouldBeEquivalentTo(new[] { "Windows" }); + } + [Fact] public void It_fails_on_unsupported_os() { diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToReferenceAProject.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToReferenceAProject.cs index 85629e57f912..9353092d2645 100644 --- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToReferenceAProject.cs +++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToReferenceAProject.cs @@ -48,6 +48,17 @@ public enum ReferenceBuildResult FailsBuild } + [RequiresMSBuildVersionTheory("16.8.0.42407")] + [InlineData("net5.0-windows", "net5.0", true)] + [InlineData("net5.0", "net5.0-windows", false)] + [InlineData("net5.0-windows", "net5.0-windows", true)] + [InlineData("net5.0-windows", "net5.0-windows7.0", true)] + [InlineData("net5.0-windows7.0", "net5.0-windows", true)] + public void It_checks_for_valid_platform_references(string referencerTarget, string dependencyTarget, bool succeeds) + { + It_checks_for_valid_references(referencerTarget, true, dependencyTarget, true, succeeds, succeeds); + } + [Theory] [InlineData("netstandard1.2", true, "netstandard1.5", true, false, false)] [InlineData("netcoreapp1.1", true, "net45;netstandard1.5", true, true, true)] diff --git a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToExcludeAPackageFromPublish.cs b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToExcludeAPackageFromPublish.cs index 81f31951bb76..fdc7a8c050a0 100644 --- a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToExcludeAPackageFromPublish.cs +++ b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToExcludeAPackageFromPublish.cs @@ -193,5 +193,33 @@ public void TransitiveNetStandardPackageReferenceAndPublishFalse() publishCommand.Execute().Should().Pass(); } + + [Fact] + public void It_does_not_exclude_packages_depended_on_by_non_privateassets_references() + { + var testProject = new TestProject() + { + Name = "PrivateAssetsTransitive", + IsSdkProject = true, + IsExe = true, + TargetFrameworks = "net5.0" + }; + + // Both these packages depend on NewtonSoft.Json. Since only one of the package references specifies PrivateAssets=All, + // NewtonSoft.Json should be included in the publish output + testProject.PackageReferences.Add(new TestPackageReference("Newtonsoft.Json.Schema", "3.0.13")); + testProject.PackageReferences.Add(new TestPackageReference("Microsoft.Extensions.DependencyModel", "3.1.6", privateAssets: "all")); + + var testAsset = _testAssetsManager.CreateTestProject(testProject); + + var publishCommand = new PublishCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name)); + publishCommand.Execute().Should().Pass(); + + var publishDirectory = publishCommand.GetOutputDirectory(testProject.TargetFrameworks); + + publishDirectory.Should().HaveFile("Newtonsoft.Json.dll"); + publishDirectory.Should().HaveFile("Newtonsoft.Json.Schema.dll"); + publishDirectory.Should().NotHaveFile("Microsoft.Extensions.DependencyModel"); + } } }