diff --git a/DotnetCLIVersion.txt b/DotnetCLIVersion.txt index d945e9ed4891..8ab6e93ac144 100644 --- a/DotnetCLIVersion.txt +++ b/DotnetCLIVersion.txt @@ -1 +1 @@ -2.0.0-preview3-006920 +2.0.2-vspre-006963 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/build/DependencyVersions.props b/build/DependencyVersions.props index 2a8238d766d3..e3f7b5973029 100644 --- a/build/DependencyVersions.props +++ b/build/DependencyVersions.props @@ -10,10 +10,10 @@ 15.2.0-preview-000093-02 2.0.0-preview1-001960 2.0.0-preview1-001960 - 4.3.0-rtm-4382 + 4.4.0-preview3-4475 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/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 diff --git a/src/Tasks/Common/src/ItemUtilities.cs b/src/Tasks/Common/src/ItemUtilities.cs index 551a22f9b812..ba6f0a45f9e0 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); @@ -130,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/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/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..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 @@ -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 Update="@(_RuntimeTargetPublishItems)" + DestinationSubPath="%(Path)" /> <_LockFileAssemblies Include="@(_RuntimeTargetPublishItems->WithMetadataValue('Type', 'assembly')->'%(ResolvedPath)')"> false 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 44b6e9a3504c..7909324e097c 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,13 +455,56 @@ 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 .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:normal"); + + buildResult.Should().Pass(); + + // 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"); + + // 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() { @@ -495,31 +538,42 @@ 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() + .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"); + 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/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"), diff --git a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildANetCoreApp.cs b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildANetCoreApp.cs index 469b214eeece..91795f46a912 100644 --- a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildANetCoreApp.cs +++ b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildANetCoreApp.cs @@ -317,6 +317,77 @@ 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:normal") + .Should() + .Pass() + .And + .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(Path.Combine("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/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"); } } } diff --git a/test/Microsoft.NET.TestFramework/RepoInfo.cs b/test/Microsoft.NET.TestFramework/RepoInfo.cs index 69b190018b96..44d218ae8975 100644 --- a/test/Microsoft.NET.TestFramework/RepoInfo.cs +++ b/test/Microsoft.NET.TestFramework/RepoInfo.cs @@ -159,6 +159,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); 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;