From d2d0353e60919faffecc4052040a0817c18286cd Mon Sep 17 00:00:00 2001 From: Piotr Puszkiewicz Date: Sat, 3 Dec 2016 14:19:54 -0800 Subject: [PATCH] Include Microsoft.Net.Sdk in CLI layout (#4895) * WiP * Update test * Working version of Net SDK * Latest SDK doesn't work as packageref * DCR + PR * Harden CLI tests against #4884 --- .../MSBuildIntegration/build.proj | 8 ++-- .../MSBuildIntegration/build.props | 5 ++- build/Microsoft.DotNet.Cli.BundledSdks.proj | 42 +++++++++++++++++++ build/Microsoft.DotNet.Cli.BundledSdks.props | 7 +++- build/Microsoft.DotNet.Cli.Compile.targets | 29 ++++++++----- ...rosoft.DotNet.Cli.DependencyVersions.props | 1 + build/sdks/sdks.csproj | 17 ++++++++ .../dotnet-cli-build/DotNetRestore.cs | 9 +++- .../Commands/TestCommand.cs | 16 +++++++ 9 files changed, 114 insertions(+), 20 deletions(-) create mode 100644 build/Microsoft.DotNet.Cli.BundledSdks.proj create mode 100755 build/sdks/sdks.csproj diff --git a/TestAssets/TestProjects/MSBuildIntegration/build.proj b/TestAssets/TestProjects/MSBuildIntegration/build.proj index 795a611c5..203f96df3 100644 --- a/TestAssets/TestProjects/MSBuildIntegration/build.proj +++ b/TestAssets/TestProjects/MSBuildIntegration/build.proj @@ -35,11 +35,11 @@ - + - + diff --git a/TestAssets/TestProjects/MSBuildIntegration/build.props b/TestAssets/TestProjects/MSBuildIntegration/build.props index 1cd8b6830..f667330b5 100644 --- a/TestAssets/TestProjects/MSBuildIntegration/build.props +++ b/TestAssets/TestProjects/MSBuildIntegration/build.props @@ -1,6 +1,7 @@ + + - - + \ No newline at end of file diff --git a/build/Microsoft.DotNet.Cli.BundledSdks.proj b/build/Microsoft.DotNet.Cli.BundledSdks.proj new file mode 100644 index 000000000..83ba01541 --- /dev/null +++ b/build/Microsoft.DotNet.Cli.BundledSdks.proj @@ -0,0 +1,42 @@ + + + + + $([MSBuild]::Unescape($(CLIBuildDll))) + + + + + + + + + + + + + + + + + + + + + $(NuGetPackagesDir)/$(SdkPackageName.ToLower())/$(SdkPackageVersion.ToLower()) + + + diff --git a/build/Microsoft.DotNet.Cli.BundledSdks.props b/build/Microsoft.DotNet.Cli.BundledSdks.props index 03d6e8894..712113017 100644 --- a/build/Microsoft.DotNet.Cli.BundledSdks.props +++ b/build/Microsoft.DotNet.Cli.BundledSdks.props @@ -1,6 +1,9 @@ + + - - + + + diff --git a/build/Microsoft.DotNet.Cli.Compile.targets b/build/Microsoft.DotNet.Cli.Compile.targets index 7cdd9ef41..019a79aed 100644 --- a/build/Microsoft.DotNet.Cli.Compile.targets +++ b/build/Microsoft.DotNet.Cli.Compile.targets @@ -244,17 +244,24 @@ - - - - - - - + + + + + CLIBuildDll=$(CLIBuildDll); + NuGetPackagesDir=$(NuGetPackagesDir); + SdkLayoutDirectory=$(SdkOutputDirectory)/Extensions/%(BundledSdk.Identity); + SdkPackageName=%(BundledSdk.Identity); + SdkPackageVersion=%(BundledSdk.Version); + Stage0Directory=$(Stage0Directory) + + + + + \ No newline at end of file diff --git a/build/Microsoft.DotNet.Cli.DependencyVersions.props b/build/Microsoft.DotNet.Cli.DependencyVersions.props index b57f677d9..8d2c23ef1 100644 --- a/build/Microsoft.DotNet.Cli.DependencyVersions.props +++ b/build/Microsoft.DotNet.Cli.DependencyVersions.props @@ -3,5 +3,6 @@ 15.1.0-preview-000451-02 1.0.0-alpha-20161104-2 + 1.0.0-alpha-20161104-2-112 diff --git a/build/sdks/sdks.csproj b/build/sdks/sdks.csproj new file mode 100755 index 000000000..cdf3c4d9c --- /dev/null +++ b/build/sdks/sdks.csproj @@ -0,0 +1,17 @@ + + + + + Library + netcoreapp1.0 + false + + + + + $(SdkPackageVersion) + + + + + diff --git a/build_projects/dotnet-cli-build/DotNetRestore.cs b/build_projects/dotnet-cli-build/DotNetRestore.cs index cd145bfc2..c074d4fba 100644 --- a/build_projects/dotnet-cli-build/DotNetRestore.cs +++ b/build_projects/dotnet-cli-build/DotNetRestore.cs @@ -12,9 +12,11 @@ namespace Microsoft.DotNet.Cli.Build protected override string Args { - get { return $"{GetProjectPath()} {GetSource()} {GetPackages()} {GetSkipInvalidConfigurations()} {GetRuntime()}"; } + get { return $"{GetProjectPath()} {GetSource()} {GetPackages()} {GetSkipInvalidConfigurations()} {GetRuntime()} {GetAdditionalParameters()}"; } } + public string AdditionalParameters { get; set; } + public string ProjectPath { get; set; } public string Source { get; set; } @@ -74,5 +76,10 @@ namespace Microsoft.DotNet.Cli.Build return null; } + + private string GetAdditionalParameters() + { + return AdditionalParameters; + } } } diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/TestCommand.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/TestCommand.cs index 28a98d4d5..234bd87f5 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/TestCommand.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/TestCommand.cs @@ -25,6 +25,8 @@ namespace Microsoft.DotNet.Tools.Test.Utilities private List> _writeLines = new List>(); + private List _cliGeneratedEnvironmentVariables = new List { "MSBuildSDKsPath" }; + public TestCommand(string command) { _command = command; @@ -178,6 +180,8 @@ namespace Microsoft.DotNet.Tools.Test.Utilities UseShellExecute = false }; + RemoveCliGeneratedEnvironmentVariables(psi); + foreach (var item in Environment) { #if NET451 @@ -219,5 +223,17 @@ namespace Microsoft.DotNet.Tools.Test.Utilities return $" in pwd {WorkingDirectory}"; } + + private void RemoveCliGeneratedEnvironmentVariables(ProcessStartInfo psi) + { + foreach (var name in _cliGeneratedEnvironmentVariables) + { +#if NET451 + psi.EnvironmentVariables.Remove(name); +#else + psi.Environment.Remove(name); +#endif + } + } } } \ No newline at end of file