From df2abd257f3e6794b9a93cc774aebb1dbb0b79a0 Mon Sep 17 00:00:00 2001 From: Daniel Plaisted Date: Wed, 16 Aug 2017 17:47:02 -0700 Subject: [PATCH 01/17] Insert NuGet Build 4.4.0-preview1-4365 and corresponding CLI version into SDK --- DotnetCLIVersion.txt | 2 +- build/DependencyVersions.props | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DotnetCLIVersion.txt b/DotnetCLIVersion.txt index d945e9ed4891..3def9297a559 100644 --- a/DotnetCLIVersion.txt +++ b/DotnetCLIVersion.txt @@ -1 +1 @@ -2.0.0-preview3-006920 +2.0.2-vspre-006933 diff --git a/build/DependencyVersions.props b/build/DependencyVersions.props index 2a8238d766d3..35507b8743d7 100644 --- a/build/DependencyVersions.props +++ b/build/DependencyVersions.props @@ -10,7 +10,7 @@ 15.2.0-preview-000093-02 2.0.0-preview1-001960 2.0.0-preview1-001960 - 4.3.0-rtm-4382 + 4.4.0-preview1-4365 9.0.1 1.4.2 2.0.0-preview2-25405-01 From 2debd7b1a8429936405e9d92f0342aebc929b277 Mon Sep 17 00:00:00 2001 From: NuGet Team Bot Date: Tue, 22 Aug 2017 16:55:51 -0700 Subject: [PATCH 02/17] Insert NuGet Build 4.4.0-preview1-4434 into sdk --- build/DependencyVersions.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/DependencyVersions.props b/build/DependencyVersions.props index 35507b8743d7..6675e3ea8e32 100644 --- a/build/DependencyVersions.props +++ b/build/DependencyVersions.props @@ -10,7 +10,7 @@ 15.2.0-preview-000093-02 2.0.0-preview1-001960 2.0.0-preview1-001960 - 4.4.0-preview1-4365 + 4.4.0-preview1-4434 9.0.1 1.4.2 2.0.0-preview2-25405-01 From 623b546ccff3321f5c727f498d8d88b24b8d6caf Mon Sep 17 00:00:00 2001 From: "Rohit Agrawal (NUGET)" Date: Thu, 24 Aug 2017 10:30:51 -0700 Subject: [PATCH 03/17] fix intermediate nuspec path --- test/Microsoft.NET.TestFramework/Commands/PackCommand.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.NET.TestFramework/Commands/PackCommand.cs b/test/Microsoft.NET.TestFramework/Commands/PackCommand.cs index 1f16c865d52d..70d2b149c98d 100644 --- a/test/Microsoft.NET.TestFramework/Commands/PackCommand.cs +++ b/test/Microsoft.NET.TestFramework/Commands/PackCommand.cs @@ -16,14 +16,14 @@ public PackCommand(ITestOutputHelper log, string projectPath, string relativePat { } - public string GetIntermediateNuspecPath(string packageId = null, string packageVersion = "1.0.0") + public string GetIntermediateNuspecPath(string packageId = null, string configuration = "Debug", string packageVersion = "1.0.0") { if (packageId == null) { packageId = Path.GetFileNameWithoutExtension(ProjectFile); } - return Path.Combine(GetBaseIntermediateDirectory().FullName, $"{packageId}.{packageVersion}.nuspec"); + return Path.Combine(GetBaseIntermediateDirectory().FullName, configuration, $"{packageId}.{packageVersion}.nuspec"); } } } From 7fdfc89800facb69afd7addec94a7fdf53538d78 Mon Sep 17 00:00:00 2001 From: William Li Date: Fri, 25 Aug 2017 09:37:25 -0700 Subject: [PATCH 04/17] Update DotnetCLIVersion --- DotnetCLIVersion.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DotnetCLIVersion.txt b/DotnetCLIVersion.txt index 3def9297a559..a39371d06e9a 100644 --- a/DotnetCLIVersion.txt +++ b/DotnetCLIVersion.txt @@ -1 +1 @@ -2.0.2-vspre-006933 +2.0.2-vspre-006938 From 2df15b557b473b5c82329dcdfa5b294d866b9f60 Mon Sep 17 00:00:00 2001 From: "Eric St. John" Date: Tue, 12 Sep 2017 16:18:36 -0700 Subject: [PATCH 05/17] Update support libraries to those that are only lib. --- build/DependencyVersions.props | 2 +- ....NET.Build.Extensions.NETFramework.targets | 20 ++++--------------- ...antToBuildADesktopExeWtihNetStandardLib.cs | 2 +- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/build/DependencyVersions.props b/build/DependencyVersions.props index 6675e3ea8e32..968e46c2cf4b 100644 --- a/build/DependencyVersions.props +++ b/build/DependencyVersions.props @@ -13,7 +13,7 @@ 4.4.0-preview1-4434 9.0.1 1.4.2 - 2.0.0-preview2-25405-01 + 2.0.1-servicing-25708-01 0.2.0-beta-000042 diff --git a/src/Tasks/Microsoft.NET.Build.Extensions.Tasks/msbuildExtensions/Microsoft/Microsoft.NET.Build.Extensions/Microsoft.NET.Build.Extensions.NETFramework.targets b/src/Tasks/Microsoft.NET.Build.Extensions.Tasks/msbuildExtensions/Microsoft/Microsoft.NET.Build.Extensions/Microsoft.NET.Build.Extensions.NETFramework.targets index d9d8e3f6f72e..2162e3cc9b5f 100644 --- a/src/Tasks/Microsoft.NET.Build.Extensions.Tasks/msbuildExtensions/Microsoft/Microsoft.NET.Build.Extensions/Microsoft.NET.Build.Extensions.NETFramework.targets +++ b/src/Tasks/Microsoft.NET.Build.Extensions.Tasks/msbuildExtensions/Microsoft/Microsoft.NET.Build.Extensions/Microsoft.NET.Build.Extensions.NETFramework.targets @@ -59,15 +59,6 @@ Copyright (c) .NET Foundation. All rights reserved. - <_NETStandardLibraryNETFrameworkReference Condition="'$(_TargetFrameworkVersionWithoutV)' >= '4.7'" - Include="$(MSBuildThisFileDirectory)\net47\ref\*.dll" /> - <_NETStandardLibraryNETFrameworkReference Condition="'$(_TargetFrameworkVersionWithoutV)' >= '4.6.2'" - Include="$(MSBuildThisFileDirectory)\net462\ref\*.dll" - Exclude="@(_NETStandardLibraryNETFrameworkReference->'$(MSBuildThisFileDirectory)\net462\ref\%(FileName).dll')" /> - <_NETStandardLibraryNETFrameworkReference Condition="'$(_TargetFrameworkVersionWithoutV)' >= '4.6.1'" - Include="$(MSBuildThisFileDirectory)\net461\ref\*.dll" - Exclude="@(_NETStandardLibraryNETFrameworkReference->'$(MSBuildThisFileDirectory)\net461\ref\%(FileName).dll')" /> - <_NETStandardLibraryNETFrameworkLib Condition="'$(_TargetFrameworkVersionWithoutV)' >= '4.7'" Include="$(MSBuildThisFileDirectory)\net47\lib\*.dll" /> <_NETStandardLibraryNETFrameworkLib Condition="'$(_TargetFrameworkVersionWithoutV)' >= '4.6.2'" @@ -83,15 +74,12 @@ Copyright (c) .NET Foundation. All rights reserved. Simple references can also come from NuGet framework assemblies, hence this statement should occur after including all computed references, thus this target is scheduled after references have been raised by NuGet targets. --> - + - - false + + + false - - - false - diff --git a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildADesktopExeWtihNetStandardLib.cs b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildADesktopExeWtihNetStandardLib.cs index 7b8c17a8e245..37d09f36166a 100644 --- a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildADesktopExeWtihNetStandardLib.cs +++ b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildADesktopExeWtihNetStandardLib.cs @@ -287,7 +287,7 @@ public void It_does_not_include_netstandard_when_inbox(bool isSdk) // Add a target that replaces the facade folder with the set of netstandard support assemblies // this can be replaced by targeting the version of .NETFramework that includes netstandard inbox, // once available - var facadesDir = Path.Combine(RepoInfo.BuildExtensionsMSBuildPath, "net461", "ref\\"); + var facadesDir = Path.Combine(RepoInfo.BuildExtensionsMSBuildPath, "net461", "lib\\"); var ns = project.Root.Name.Namespace; var target = new XElement(ns + "Target", new XAttribute("Name", "ReplaceDesignTimeFacadeDirectories"), From e0c9b2787ae4c9d55fefedc19218da69f4e387c6 Mon Sep 17 00:00:00 2001 From: NuGet Team Bot Date: Wed, 13 Sep 2017 17:27:51 -0700 Subject: [PATCH 06/17] Insert NuGet Build 4.4.0-preview3-4475 into sdk --- build/DependencyVersions.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/DependencyVersions.props b/build/DependencyVersions.props index 6675e3ea8e32..b6b195e44d97 100644 --- a/build/DependencyVersions.props +++ b/build/DependencyVersions.props @@ -10,7 +10,7 @@ 15.2.0-preview-000093-02 2.0.0-preview1-001960 2.0.0-preview1-001960 - 4.4.0-preview1-4434 + 4.4.0-preview3-4475 9.0.1 1.4.2 2.0.0-preview2-25405-01 From 187bc2024f4a07faf577630324ff545876ab3275 Mon Sep 17 00:00:00 2001 From: Nick Guerrera Date: Wed, 16 Aug 2017 17:41:16 -0700 Subject: [PATCH 07/17] Disable multilevel lookup in build/test to prevent accidental machine dependencies --- build.ps1 | 3 +++ build.sh | 3 +++ 2 files changed, 6 insertions(+) diff --git a/build.ps1 b/build.ps1 index 9b5e5fdb91cd..80dd415986a4 100644 --- a/build.ps1 +++ b/build.ps1 @@ -94,6 +94,9 @@ $env:PATH = "$env:DOTNET_INSTALL_DIR;$env:PATH" # Disable first run since we want to control all package sources $env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 +# Don't resolve runtime, shared framework, or SDK from other locations +$env:DOTNET_MULTILEVEL_LOOKUP=0 + $logPath = "$RepoRoot\bin\log" if (!(Test-Path -Path $logPath)) { New-Item -Path $logPath -Force -ItemType 'Directory' | Out-Null diff --git a/build.sh b/build.sh index b41a16fedd38..7413eac8be56 100755 --- a/build.sh +++ b/build.sh @@ -92,4 +92,7 @@ export PATH="$DOTNET_INSTALL_DIR:$PATH" # Disable first run since we want to control all package sources export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 +# Don't resolve runtime, shared framework, or SDK from global locations +export DOTNET_MULTILEVEL_LOOKUP=0 + dotnet msbuild $REPOROOT/build/build.proj /m:1 /nologo /p:Configuration=$CONFIGURATION /p:Platform="$PLATFORM" "${args[@]}" /warnaserror From 82888a04ed300bbc6bcb1ffaf57fb7af011ca731 Mon Sep 17 00:00:00 2001 From: Daniel Plaisted Date: Tue, 5 Sep 2017 19:47:42 -0700 Subject: [PATCH 08/17] Disable multilevel lookup for Tests This is already set in the build script, but setting it here will apply to scenarios such as running tests from VS --- test/Microsoft.NET.TestFramework/RepoInfo.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/Microsoft.NET.TestFramework/RepoInfo.cs b/test/Microsoft.NET.TestFramework/RepoInfo.cs index 21e7f81972c1..42342d21b9bd 100644 --- a/test/Microsoft.NET.TestFramework/RepoInfo.cs +++ b/test/Microsoft.NET.TestFramework/RepoInfo.cs @@ -150,6 +150,8 @@ public static ICommand AddTestEnvironmentVariables(ICommand command) // Set NUGET_PACKAGES environment variable to match value from build.ps1 command = command.EnvironmentVariable("NUGET_PACKAGES", RepoInfo.NuGetCachePath); + command = command.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0"); + command = command.EnvironmentVariable("MSBuildSDKsPath", RepoInfo.SdksPath); command = command.EnvironmentVariable("DOTNET_MSBUILD_SDK_RESOLVER_SDKS_DIR", RepoInfo.SdksPath); From 28102a061ddbb2a5b4161cd7dacc5f04804b6319 Mon Sep 17 00:00:00 2001 From: Daniel Plaisted Date: Tue, 5 Sep 2017 19:49:27 -0700 Subject: [PATCH 09/17] Use correct target path for runtimeTargets items when resolving conflicts Fixes #1510 --- src/Tasks/Common/src/ItemUtilities.cs | 4 +- .../Microsoft.NET.ConflictResolution.targets | 8 +++- .../GivenThatWeWantToBuildADesktopExe.cs | 44 +++++++++++++++++++ .../GivenThatWeWantToBuildANetCoreApp.cs | 24 ++++++++++ 4 files changed, 77 insertions(+), 3 deletions(-) diff --git a/src/Tasks/Common/src/ItemUtilities.cs b/src/Tasks/Common/src/ItemUtilities.cs index 551a22f9b812..e776c6d3f8df 100644 --- a/src/Tasks/Common/src/ItemUtilities.cs +++ b/src/Tasks/Common/src/ItemUtilities.cs @@ -116,7 +116,9 @@ public static string GetSourcePath(ITaskItem item) static readonly string[] s_targetPathMetadata = new[] { MetadataNames.TargetPath, MetadataNames.DestinationSubPath }; public static string GetTargetPath(ITaskItem item) { - // first use TargetPath, DestinationSubPath, then Path, then fallback to filename+extension alone + // first use TargetPath, then DestinationSubPath, then fallback to filename+extension alone + // Can't use Path, as this is the path of the file in the package, which is usually not the target path + // (for example the target path for lib/netcoreapp2.0/lib.dll is just lib.dll) foreach (var metadata in s_targetPathMetadata) { var value = item.GetMetadata(metadata); diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.ConflictResolution.targets b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.ConflictResolution.targets index 0a53a4a01d8a..83b5534f54bf 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.ConflictResolution.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.ConflictResolution.targets @@ -32,10 +32,14 @@ Copyright (c) .NET Foundation. All rights reserved. + for conflict resolution. Set DestinationSubPath for these items so that conflict resolution will consider + that path (for example "runtimes/win/lib/netstandard1.3/System.Diagnostics.TraceSource.dll" when looking + for conflicts). --> <_RuntimeTargetItems Include="@(_ActiveTFMFileDependencies->WithMetadataValue('FileGroup', 'RuntimeTarget'))" /> <__RuntimeTargetPublishItems Include="@(FileDefinitions)" Exclude="@(_RuntimeTargetItems)" /> - <_RuntimeTargetPublishItems Include="@(FileDefinitions)" Exclude="@(__RuntimeTargetPublishItems)" /> + <_RuntimeTargetPublishItems Include="@(FileDefinitions)" Exclude="@(__RuntimeTargetPublishItems)" + DestinationSubPath="%(FileDefinitions.Path)" + /> <_LockFileAssemblies Include="@(_RuntimeTargetPublishItems->WithMetadataValue('Type', 'assembly')->'%(ResolvedPath)')"> false diff --git a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildADesktopExe.cs b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildADesktopExe.cs index 44b6e9a3504c..8b605a6ad01d 100644 --- a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildADesktopExe.cs +++ b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildADesktopExe.cs @@ -462,6 +462,50 @@ public void It_does_not_report_conflicts_when_referencing_a_nuget_package() .NotHaveStdOutMatching("Encountered conflict", System.Text.RegularExpressions.RegexOptions.CultureInvariant | System.Text.RegularExpressions.RegexOptions.IgnoreCase); } + [WindowsOnlyFact] + public void It_does_not_report_conflicts_with_runtime_specific_items() + { + var testProject = new TestProject() + { + Name = "DesktopConflictsRuntimeTargets", + TargetFrameworks = "net461", + IsSdkProject = true, + IsExe = true + }; + + testProject.AdditionalProperties["PlatformTarget"] = "AnyCPU"; + + var testAsset = _testAssetsManager.CreateTestProject(testProject, testProject.Name) + .WithProjectChanges(p => + { + var ns = p.Root.Name.Namespace; + + + + var itemGroup = new XElement(ns + "ItemGroup"); + p.Root.Add(itemGroup); + + itemGroup.Add(new XElement(ns + "PackageReference", + new XAttribute("Include", "System.Security.Cryptography.Algorithms"), + new XAttribute("Version", "4.3.0"))); + }) + .Restore(Log, testProject.Name); + + var buildCommand = new BuildCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name)); + + var buildResult = buildCommand + .Execute("/v:diag"); + + buildResult.Should().Pass(); + + // Correct asset should be copied to output folder + var outputDirectory = buildCommand.GetOutputDirectory(testProject.TargetFrameworks); + outputDirectory.Should().HaveFile("System.Security.Cryptography.Algorithms.dll"); + + // There should be no conflicts + buildResult.Should().NotHaveStdOutMatching("Encountered conflict", System.Text.RegularExpressions.RegexOptions.CultureInvariant | System.Text.RegularExpressions.RegexOptions.IgnoreCase); + } + [Fact] public void It_generates_binding_redirects_if_needed() { diff --git a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildANetCoreApp.cs b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildANetCoreApp.cs index c7f51e9b1675..039e09b4a50e 100644 --- a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildANetCoreApp.cs +++ b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildANetCoreApp.cs @@ -312,6 +312,30 @@ public static void Main() } } + [Fact] + public void There_are_no_conflicts_when_targeting_netcoreapp_1_1() + { + var testProject = new TestProject() + { + Name = "NetCoreApp1.1_Conflicts", + TargetFrameworks = "netcoreapp1.1", + IsSdkProject = true, + IsExe = true + }; + + var testAsset = _testAssetsManager.CreateTestProject(testProject, testProject.Name) + .Restore(Log, testProject.Name); + + var buildCommand = new BuildCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name)); + + buildCommand + .Execute("/v:diag") + .Should() + .Pass() + .And + .NotHaveStdOutMatching("Encountered conflict", System.Text.RegularExpressions.RegexOptions.CultureInvariant | System.Text.RegularExpressions.RegexOptions.IgnoreCase); + } + [Fact] public void It_uses_lowercase_form_of_the_target_framework_for_the_output_path() { From db98a33c3443fdf7516f3685c64a2412f86a9c36 Mon Sep 17 00:00:00 2001 From: Daniel Plaisted Date: Tue, 5 Sep 2017 21:56:48 -0700 Subject: [PATCH 10/17] Change log verbosity to normal when checking whether projects encounter conflicts --- .../GivenThatWeWantToBuildADesktopExe.cs | 6 +++--- .../GivenThatWeWantToBuildANetCoreApp.cs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildADesktopExe.cs b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildADesktopExe.cs index 8b605a6ad01d..0b2359bfdc32 100644 --- a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildADesktopExe.cs +++ b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildADesktopExe.cs @@ -415,7 +415,7 @@ public void It_does_not_report_conflicts_if_the_same_framework_assembly_is_refer var buildCommand = new BuildCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name)); buildCommand - .Execute("/v:diag") + .Execute("/v:normal") .Should() .Pass() .And @@ -455,7 +455,7 @@ public void It_does_not_report_conflicts_when_referencing_a_nuget_package() var buildCommand = new BuildCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name)); buildCommand - .Execute("/v:diag") + .Execute("/v:normal") .Should() .Pass() .And @@ -494,7 +494,7 @@ public void It_does_not_report_conflicts_with_runtime_specific_items() var buildCommand = new BuildCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name)); var buildResult = buildCommand - .Execute("/v:diag"); + .Execute("/v:normal"); buildResult.Should().Pass(); diff --git a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildANetCoreApp.cs b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildANetCoreApp.cs index 039e09b4a50e..1ca26d4e20d3 100644 --- a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildANetCoreApp.cs +++ b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildANetCoreApp.cs @@ -329,7 +329,7 @@ public void There_are_no_conflicts_when_targeting_netcoreapp_1_1() var buildCommand = new BuildCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name)); buildCommand - .Execute("/v:diag") + .Execute("/v:normal") .Should() .Pass() .And From 7bdd496df3a7f5e43b4b9f58a5fec26f8d2fae31 Mon Sep 17 00:00:00 2001 From: Daniel Plaisted Date: Thu, 7 Sep 2017 13:15:22 -0700 Subject: [PATCH 11/17] Add comment clarifying test expectation --- .../GivenThatWeWantToBuildADesktopExe.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildADesktopExe.cs b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildADesktopExe.cs index 0b2359bfdc32..78a2df581226 100644 --- a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildADesktopExe.cs +++ b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildADesktopExe.cs @@ -498,7 +498,9 @@ public void It_does_not_report_conflicts_with_runtime_specific_items() buildResult.Should().Pass(); - // Correct asset should be copied to output folder + // Correct asset should be copied to output folder. Before fixing https://github.com/dotnet/sdk/issues/1510, + // the runtimeTargets items would win conflict resolution, and then would not be copied to the output folder, + // so there'd be no copy of the DLL in the output folder. var outputDirectory = buildCommand.GetOutputDirectory(testProject.TargetFrameworks); outputDirectory.Should().HaveFile("System.Security.Cryptography.Algorithms.dll"); From a5b05029b8b3d66820e5b861c8ced99f4f00aace Mon Sep 17 00:00:00 2001 From: Daniel Plaisted Date: Thu, 7 Sep 2017 13:50:00 -0700 Subject: [PATCH 12/17] Take locale portion of target path for satellite assemblies into account in conflict resolution Fixes #1465 --- src/Tasks/Common/src/ItemUtilities.cs | 12 +++++++++++- .../GivenThatWeWantToBuildADesktopExe.cs | 9 ++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/Tasks/Common/src/ItemUtilities.cs b/src/Tasks/Common/src/ItemUtilities.cs index e776c6d3f8df..ba6f0a45f9e0 100644 --- a/src/Tasks/Common/src/ItemUtilities.cs +++ b/src/Tasks/Common/src/ItemUtilities.cs @@ -132,7 +132,17 @@ public static string GetTargetPath(ITaskItem item) var sourcePath = GetSourcePath(item); - return Path.GetFileName(sourcePath); + var fileName = Path.GetFileName(sourcePath); + + // Get locale subdirectory for satellite assemblies + var destinationSubDirectory = item.GetMetadata("DestinationSubDirectory"); + + if (!string.IsNullOrWhiteSpace(destinationSubDirectory)) + { + return Path.Combine(destinationSubDirectory, fileName); + } + + return fileName; } } } diff --git a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildADesktopExe.cs b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildADesktopExe.cs index 78a2df581226..9ad6d46048c7 100644 --- a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildADesktopExe.cs +++ b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildADesktopExe.cs @@ -479,9 +479,6 @@ public void It_does_not_report_conflicts_with_runtime_specific_items() .WithProjectChanges(p => { var ns = p.Root.Name.Namespace; - - - var itemGroup = new XElement(ns + "ItemGroup"); p.Root.Add(itemGroup); @@ -561,9 +558,11 @@ public void It_places_package_satellites_correctly(bool crossTarget) var buildCommand = new BuildCommand(Log, testAsset.TestRoot); buildCommand - .Execute() + .Execute("/v:normal") .Should() - .Pass(); + .Pass() + .And + .NotHaveStdOutMatching("Encountered conflict", System.Text.RegularExpressions.RegexOptions.CultureInvariant | System.Text.RegularExpressions.RegexOptions.IgnoreCase); var outputDirectory = buildCommand.GetOutputDirectory("net46"); outputDirectory.Should().NotHaveFile("FluentValidation.resources.dll"); From ebbf880e2bae5d488bf8b6b595949260657bc653 Mon Sep 17 00:00:00 2001 From: Daniel Plaisted Date: Mon, 11 Sep 2017 12:09:04 -0700 Subject: [PATCH 13/17] Fix satellite assembly conflict resolution when targeting .NET Core --- .../DesktopUsingPackageWithSatellites.csproj | 12 ----- .../Program.cs | 15 ------ ...rosoft.PackageDependencyResolution.targets | 19 ++++++-- .../GivenThatWeWantToBuildADesktopExe.cs | 37 +++++++++------ .../GivenThatWeWantToBuildANetCoreApp.cs | 47 +++++++++++++++++++ .../TestPackageReference.cs | 5 ++ 6 files changed, 89 insertions(+), 46 deletions(-) delete mode 100644 TestAssets/TestProjects/DesktopUsingPackageWithSatellites/DesktopUsingPackageWithSatellites.csproj delete mode 100644 TestAssets/TestProjects/DesktopUsingPackageWithSatellites/Program.cs diff --git a/TestAssets/TestProjects/DesktopUsingPackageWithSatellites/DesktopUsingPackageWithSatellites.csproj b/TestAssets/TestProjects/DesktopUsingPackageWithSatellites/DesktopUsingPackageWithSatellites.csproj deleted file mode 100644 index 2ff0fb12dc8a..000000000000 --- a/TestAssets/TestProjects/DesktopUsingPackageWithSatellites/DesktopUsingPackageWithSatellites.csproj +++ /dev/null @@ -1,12 +0,0 @@ - - - - Exe - net46 - - - - - - - \ No newline at end of file diff --git a/TestAssets/TestProjects/DesktopUsingPackageWithSatellites/Program.cs b/TestAssets/TestProjects/DesktopUsingPackageWithSatellites/Program.cs deleted file mode 100644 index 497c08f8fda8..000000000000 --- a/TestAssets/TestProjects/DesktopUsingPackageWithSatellites/Program.cs +++ /dev/null @@ -1,15 +0,0 @@ -// 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. - -using System; - -namespace TestApp -{ - class Program - { - static void Main() - { - Console.WriteLine("Hello World"); - } - } -} diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.PackageDependencyResolution.targets b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.PackageDependencyResolution.targets index 36b9b302206a..a8987149871c 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.PackageDependencyResolution.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.PackageDependencyResolution.targets @@ -517,8 +517,20 @@ Copyright (c) .NET Foundation. All rights reserved. <_ResourceFileItems Include="@(_ActiveTFMFileDependencies->WithMetadataValue('FileGroup', 'ResourceAssembly'))" /> <__ResourceCopyLocalItems Include="@(FileDefinitions)" Exclude="@(_ResourceFileItems)" /> + + <_ResourceCopyLocalItems Include="@(FileDefinitions)" Exclude="@(__ResourceCopyLocalItems)" /> - + <_ResourceCopyLocalItems Update="@(_ResourceCopyLocalItems)" Condition="'@(_ResourceCopyLocalItems)' != ''"> + $([System.IO.Directory]::GetParent(%(ResolvedPath)).get_Name())\ + + + %(_ResourceCopyLocalItems.DestinationSubDirectory) + <_AllCopyLocalItems Include="@(_NativeCopyLocalItems);@(_RuntimeCopyLocalItems);@(_ResourceCopyLocalItems)" /> @@ -548,10 +560,7 @@ Copyright (c) .NET Foundation. All rights reserved. - - - $([System.IO.Directory]::GetParent(%(ResourceCopyLocalItems.FullPath)).get_Name())\ - + diff --git a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildADesktopExe.cs b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildADesktopExe.cs index 9ad6d46048c7..7909324e097c 100644 --- a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildADesktopExe.cs +++ b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildADesktopExe.cs @@ -538,25 +538,34 @@ public void It_generates_binding_redirects_if_needed() [InlineData(false)] public void It_places_package_satellites_correctly(bool crossTarget) { - var testAsset = _testAssetsManager - .CopyTestAsset( - "DesktopUsingPackageWithSatellites", - identifier: crossTarget ? "_cross" : "") - .WithSource(); + var testProject = new TestProject() + { + Name = "DesktopUsingPackageWithSatellites", + TargetFrameworks = "net46", + IsSdkProject = true, + IsExe = true + }; if (crossTarget) { - testAsset = testAsset.WithProjectChanges(project => - { - var ns = project.Root.Name.Namespace; - var propertyGroup = project.Root.Elements(ns + "PropertyGroup").First(); - propertyGroup.Element(ns + "TargetFramework").Name += "s"; - }); + testProject.Name += "_cross"; } - testAsset.Restore(Log); + testProject.PackageReferences.Add(new TestPackageReference("FluentValidation", "5.5.0")); - var buildCommand = new BuildCommand(Log, testAsset.TestRoot); + var testAsset = _testAssetsManager.CreateTestProject(testProject, testProject.Name) + .WithProjectChanges(project => + { + if (crossTarget) + { + var ns = project.Root.Name.Namespace; + var propertyGroup = project.Root.Elements(ns + "PropertyGroup").First(); + propertyGroup.Element(ns + "TargetFramework").Name += "s"; + } + }) + .Restore(Log, testProject.Name); + + var buildCommand = new BuildCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name)); buildCommand .Execute("/v:normal") .Should() @@ -564,7 +573,7 @@ public void It_places_package_satellites_correctly(bool crossTarget) .And .NotHaveStdOutMatching("Encountered conflict", System.Text.RegularExpressions.RegexOptions.CultureInvariant | System.Text.RegularExpressions.RegexOptions.IgnoreCase); - var outputDirectory = buildCommand.GetOutputDirectory("net46"); + var outputDirectory = buildCommand.GetOutputDirectory(testProject.TargetFrameworks); outputDirectory.Should().NotHaveFile("FluentValidation.resources.dll"); outputDirectory.Should().HaveFile(@"fr\FluentValidation.resources.dll"); } diff --git a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildANetCoreApp.cs b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildANetCoreApp.cs index 1ca26d4e20d3..1cc0b5a97d0a 100644 --- a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildANetCoreApp.cs +++ b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildANetCoreApp.cs @@ -336,6 +336,53 @@ public void There_are_no_conflicts_when_targeting_netcoreapp_1_1() .NotHaveStdOutMatching("Encountered conflict", System.Text.RegularExpressions.RegexOptions.CultureInvariant | System.Text.RegularExpressions.RegexOptions.IgnoreCase); } + [Theory] + [InlineData(true)] + [InlineData(false)] + public void It_publishes_package_satellites_correctly(bool crossTarget) + { + var testProject = new TestProject() + { + Name = "AppUsingPackageWithSatellites", + TargetFrameworks = "netcoreapp2.0", + IsSdkProject = true, + IsExe = true + }; + + if (crossTarget) + { + testProject.Name += "_cross"; + } + + testProject.PackageReferences.Add(new TestPackageReference("Humanizer.Core.fr", "2.2.0")); + testProject.PackageReferences.Add(new TestPackageReference("Humanizer.Core.pt", "2.2.0")); + + var testAsset = _testAssetsManager.CreateTestProject(testProject, testProject.Name) + .WithProjectChanges(project => + { + if (crossTarget) + { + var ns = project.Root.Name.Namespace; + var propertyGroup = project.Root.Elements(ns + "PropertyGroup").First(); + propertyGroup.Element(ns + "TargetFramework").Name += "s"; + } + }) + .Restore(Log, testProject.Name); + + var publishCommand = new PublishCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name)); + publishCommand + .Execute("/v:normal", $"/p:TargetFramework={testProject.TargetFrameworks}") + .Should() + .Pass() + .And + .NotHaveStdOutMatching("Encountered conflict", System.Text.RegularExpressions.RegexOptions.CultureInvariant | System.Text.RegularExpressions.RegexOptions.IgnoreCase) + ; + + var outputDirectory = publishCommand.GetOutputDirectory(testProject.TargetFrameworks); + outputDirectory.Should().NotHaveFile("Humanizer.resources.dll"); + outputDirectory.Should().HaveFile(@"fr\Humanizer.resources.dll"); + } + [Fact] public void It_uses_lowercase_form_of_the_target_framework_for_the_output_path() { diff --git a/test/Microsoft.NET.TestFramework/TestPackageReference.cs b/test/Microsoft.NET.TestFramework/TestPackageReference.cs index 3f1185307a9a..3f695f9887cc 100644 --- a/test/Microsoft.NET.TestFramework/TestPackageReference.cs +++ b/test/Microsoft.NET.TestFramework/TestPackageReference.cs @@ -11,6 +11,11 @@ namespace Microsoft.NET.TestFramework { public class TestPackageReference { + public TestPackageReference(string id, string version) + : this(id, version, null) + { + } + public TestPackageReference(string id, string version, string nupkgPath) { ID = id; From 2955e559097eddbb0e5de2a5e4407a88df25e559 Mon Sep 17 00:00:00 2001 From: Daniel Plaisted Date: Tue, 12 Sep 2017 18:41:15 -0700 Subject: [PATCH 14/17] Add build/test environment scripts --- build/sdk-build-env.bat | 18 ++++++++++++++++++ build/sdk-build-env.sh | 23 +++++++++++++++++++++++ build/sdk-test-env.bat | 22 ++++++++++++++++++++++ build/sdk-test-env.sh | 27 +++++++++++++++++++++++++++ 4 files changed, 90 insertions(+) create mode 100644 build/sdk-build-env.bat create mode 100644 build/sdk-build-env.sh create mode 100644 build/sdk-test-env.bat create mode 100644 build/sdk-test-env.sh diff --git a/build/sdk-build-env.bat b/build/sdk-build-env.bat new file mode 100644 index 000000000000..19d5a8b38c02 --- /dev/null +++ b/build/sdk-build-env.bat @@ -0,0 +1,18 @@ +@echo off + +REM Copyright (c) .NET Foundation and contributors. All rights reserved. +REM Licensed under the MIT license. See LICENSE file in the project root for full license information. + +REM Get normalized version of parent path +for %%i in (%~dp0..\) DO ( + SET SDK_REPO_ROOT=%%~dpi +) + +title SDK Build (%SDK_REPO_ROOT%) +set PATH=%SDK_REPO_ROOT%.dotnet_cli;%PATH% +set /P SDK_CLI_VERSION=<%SDK_REPO_ROOT%DotnetCLIVersion.txt +rem set DOTNET_MSBUILD_SDK_RESOLVER_SDKS_DIR=%SDK_REPO_ROOT%.dotnet_cli\sdk\%SDK_CLI_VERSION%\Sdks +set DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 +set DOTNET_MULTILEVEL_LOOKUP=0 + +set NUGET_PACKAGES=%SDK_REPO_ROOT%packages \ No newline at end of file diff --git a/build/sdk-build-env.sh b/build/sdk-build-env.sh new file mode 100644 index 000000000000..1a0c39a2abc0 --- /dev/null +++ b/build/sdk-build-env.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +# +# 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. +# + +SOURCE="${BASH_SOURCE[0]}" +while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink + DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + SOURCE="$(readlink "$SOURCE")" + [[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located +done + +REPO_ROOT="$( cd -P "$( dirname "$SOURCE" )/../" && pwd )" + +STAGE0_DIR=$REPO_ROOT/.dotnet_cli +export PATH=$STAGE0_DIR:$PATH + + +export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 +export DOTNET_MULTILEVEL_LOOKUP=0 + +export NUGET_PACKAGES=$REPO_ROOT/packages diff --git a/build/sdk-test-env.bat b/build/sdk-test-env.bat new file mode 100644 index 000000000000..6add11c6ba7d --- /dev/null +++ b/build/sdk-test-env.bat @@ -0,0 +1,22 @@ +@echo off + +REM Copyright (c) .NET Foundation and contributors. All rights reserved. +REM Licensed under the MIT license. See LICENSE file in the project root for full license information. + +REM Get normalized version of parent path +for %%i in (%~dp0..\) DO ( + SET SDK_REPO_ROOT=%%~dpi +) + +title SDK Test (%SDK_REPO_ROOT%) +set DOTNET_MULTILEVEL_LOOKUP=0 +set PATH=%SDK_REPO_ROOT%.dotnet_cli;%PATH% +set NUGET_PACKAGES=%SDK_REPO_ROOT%packages +set /P SDK_CLI_VERSION=<%SDK_REPO_ROOT%DotnetCLIVersion.txt +set DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 +set MSBuildSDKsPath=%SDK_REPO_ROOT%bin\Debug\Sdks +set DOTNET_MSBUILD_SDK_RESOLVER_SDKS_DIR=%SDK_REPO_ROOT%bin\Debug\Sdks +set NETCoreSdkBundledVersionsProps=%SDK_REPO_ROOT%.dotnet_cli\sdk\%SDK_CLI_VERSION%\Microsoft.NETCoreSdk.BundledVersions.props +set CustomAfterMicrosoftCommonTargets=%SDK_REPO_ROOT%bin\Debug\Sdks\Microsoft.NET.Build.Extensions\msbuildExtensions-ver\Microsoft.Common.Targets\ImportAfter\Microsoft.NET.Build.Extensions.targets +set MicrosoftNETBuildExtensionsTargets=%SDK_REPO_ROOT%bin\Debug\Sdks\Microsoft.NET.Build.Extensions\msbuildExtensions\Microsoft\Microsoft.NET.Build.Extensions\Microsoft.NET.Build.Extensions.targets +rem You also need to add https://dotnet.myget.org/F/dotnet-core/api/v3/index.json to your NuGet feeds if building projects outside the SDK cone \ No newline at end of file diff --git a/build/sdk-test-env.sh b/build/sdk-test-env.sh new file mode 100644 index 000000000000..9d67ff274833 --- /dev/null +++ b/build/sdk-test-env.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +# +# 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. +# + +SOURCE="${BASH_SOURCE[0]}" +while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink + DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + SOURCE="$(readlink "$SOURCE")" + [[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located +done + +REPO_ROOT="$( cd -P "$( dirname "$SOURCE" )/../" && pwd )" + +STAGE0_DIR=$REPO_ROOT/.dotnet_cli +SDK_CLI_VERSION="$( cat $REPO_ROOT/DotnetCLIVersion.txt )" + +export DOTNET_MULTILEVEL_LOOKUP=0 +export PATH=$STAGE0_DIR:$PATH +export NUGET_PACKAGES=$REPO_ROOT/packages +export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 +export MSBuildSDKsPath=$REPO_ROOT/bin/Debug/Sdks +export DOTNET_MSBUILD_SDK_RESOLVER_SDKS_DIR=$REPO_ROOT/bin/Debug/Sdks +export NETCoreSdkBundledVersionsProps=$REPO_ROOT/.dotnet_cli/sdk/%SDK_CLI_VERSION%/Microsoft.NETCoreSdk.BundledVersions.props +export CustomAfterMicrosoftCommonTargets=$REPO_ROOT/bin/Debug/Sdks/Microsoft.NET.Build.Extensions/msbuildExtensions-ver/Microsoft.Common.Targets/ImportAfter/Microsoft.NET.Build.Extensions.targets +export MicrosoftNETBuildExtensionsTargets=$REPO_ROOT/bin/Debug/Sdks/Microsoft.NET.Build.Extensions/msbuildExtensions/Microsoft/Microsoft.NET.Build.Extensions/Microsoft.NET.Build.Extensions.targets From 34da6b619907213d5e532b546445668e24e938b8 Mon Sep 17 00:00:00 2001 From: Daniel Plaisted Date: Wed, 13 Sep 2017 14:30:26 -0700 Subject: [PATCH 15/17] Fix perf regression with setting DestinationSubPath on items for conflict resolution See https://github.com/Microsoft/msbuild/issues/2516 for details of the perf issue --- .../build/Microsoft.NET.ConflictResolution.targets | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.ConflictResolution.targets b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.ConflictResolution.targets index 83b5534f54bf..db4c48112189 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.ConflictResolution.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.ConflictResolution.targets @@ -37,9 +37,9 @@ Copyright (c) .NET Foundation. All rights reserved. for conflicts). --> <_RuntimeTargetItems Include="@(_ActiveTFMFileDependencies->WithMetadataValue('FileGroup', 'RuntimeTarget'))" /> <__RuntimeTargetPublishItems Include="@(FileDefinitions)" Exclude="@(_RuntimeTargetItems)" /> - <_RuntimeTargetPublishItems Include="@(FileDefinitions)" Exclude="@(__RuntimeTargetPublishItems)" - DestinationSubPath="%(FileDefinitions.Path)" - /> + <_RuntimeTargetPublishItems Include="@(FileDefinitions)" Exclude="@(__RuntimeTargetPublishItems)" /> + <_RuntimeTargetPublishItems Update="@(_RuntimeTargetPublishItems)" + DestinationSubPath="%(Path)" /> <_LockFileAssemblies Include="@(_RuntimeTargetPublishItems->WithMetadataValue('Type', 'assembly')->'%(ResolvedPath)')"> false From 65bb756167fca5bd9f8807153489eadd069ec981 Mon Sep 17 00:00:00 2001 From: Daniel Plaisted Date: Wed, 13 Sep 2017 14:50:37 -0700 Subject: [PATCH 16/17] Fix test issue with path separator character --- .../GivenThatWeWantToBuildANetCoreApp.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildANetCoreApp.cs b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildANetCoreApp.cs index 1cc0b5a97d0a..025043aa4ded 100644 --- a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildANetCoreApp.cs +++ b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildANetCoreApp.cs @@ -380,7 +380,7 @@ public void It_publishes_package_satellites_correctly(bool crossTarget) var outputDirectory = publishCommand.GetOutputDirectory(testProject.TargetFrameworks); outputDirectory.Should().NotHaveFile("Humanizer.resources.dll"); - outputDirectory.Should().HaveFile(@"fr\Humanizer.resources.dll"); + outputDirectory.Should().HaveFile(Path.Combine("fr", "Humanizer.resources.dll")); } [Fact] From f4661d428cd1003a08ec303ce9dba370ae283b55 Mon Sep 17 00:00:00 2001 From: Daniel Plaisted Date: Wed, 20 Sep 2017 23:25:17 -0700 Subject: [PATCH 17/17] Update CLI version --- DotnetCLIVersion.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DotnetCLIVersion.txt b/DotnetCLIVersion.txt index a39371d06e9a..8ab6e93ac144 100644 --- a/DotnetCLIVersion.txt +++ b/DotnetCLIVersion.txt @@ -1 +1 @@ -2.0.2-vspre-006938 +2.0.2-vspre-006963