diff --git a/.gitignore b/.gitignore index 3fc22dc00..7bed92752 100644 --- a/.gitignore +++ b/.gitignore @@ -115,6 +115,7 @@ artifacts/ *.tmp *.tmp_proj *.log +*.binlog *.vspscc *.vssscc .builds diff --git a/NuGet.Config b/NuGet.Config index e7b530794..120a5daf6 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -5,13 +5,13 @@ - + + - diff --git a/TestAssets/DesktopTestProjects/AppWithProjTool2Fx/App.csproj b/TestAssets/DesktopTestProjects/AppWithProjTool2Fx/App.csproj index ba40187cd..f52962bc8 100644 --- a/TestAssets/DesktopTestProjects/AppWithProjTool2Fx/App.csproj +++ b/TestAssets/DesktopTestProjects/AppWithProjTool2Fx/App.csproj @@ -6,8 +6,6 @@ Exe $(PackageTargetFallback);portable-net45+win8;dnxcore50 win7-x64;win7-x86;osx.10.10-x64;osx.10.11-x64;ubuntu.14.04-x64;ubuntu.16.04-x64;ubuntu.16.10-x64;centos.7-x64;rhel.7.2-x64;debian.8-x64;fedora.24-x64;opensuse.42.1-x64 - $(CLI_SharedFrameworkVersion) - netcoreapp1.1 diff --git a/TestAssets/DesktopTestProjects/BindingRedirectSample/AppWithRedirectsAndConfig/AppWithRedirectsAndConfig.csproj b/TestAssets/DesktopTestProjects/BindingRedirectSample/AppWithRedirectsAndConfig/AppWithRedirectsAndConfig.csproj index 9ab6d1e5a..82a5ad25d 100644 --- a/TestAssets/DesktopTestProjects/BindingRedirectSample/AppWithRedirectsAndConfig/AppWithRedirectsAndConfig.csproj +++ b/TestAssets/DesktopTestProjects/BindingRedirectSample/AppWithRedirectsAndConfig/AppWithRedirectsAndConfig.csproj @@ -4,7 +4,6 @@ AppWithRedirectsAndConfig Exe win7-x64;win7-x86 - netcoreapp1.1 diff --git a/TestAssets/DesktopTestProjects/BindingRedirectSample/AppWithRedirectsNoConfig/AppWithRedirectsNoConfig.csproj b/TestAssets/DesktopTestProjects/BindingRedirectSample/AppWithRedirectsNoConfig/AppWithRedirectsNoConfig.csproj index aa1b27d15..94b99d56b 100644 --- a/TestAssets/DesktopTestProjects/BindingRedirectSample/AppWithRedirectsNoConfig/AppWithRedirectsNoConfig.csproj +++ b/TestAssets/DesktopTestProjects/BindingRedirectSample/AppWithRedirectsNoConfig/AppWithRedirectsNoConfig.csproj @@ -4,7 +4,6 @@ AppWithRedirectsNoConfig Exe win7-x64;win7-x86 - netcoreapp1.1 diff --git a/TestAssets/DesktopTestProjects/LibWithProjTool2Fx/Lib.csproj b/TestAssets/DesktopTestProjects/LibWithProjTool2Fx/Lib.csproj index 51192f708..e0865b59b 100644 --- a/TestAssets/DesktopTestProjects/LibWithProjTool2Fx/Lib.csproj +++ b/TestAssets/DesktopTestProjects/LibWithProjTool2Fx/Lib.csproj @@ -3,7 +3,6 @@ netstandard1.6;net451 Library $(PackageTargetFallback);portable-net45+win8;dnxcore50;netcoreapp2.0 - netcoreapp1.1 diff --git a/TestAssets/NonRestoredTestProjects/AppThrowingException/App/AppThrowingException.csproj b/TestAssets/NonRestoredTestProjects/AppThrowingException/App/AppThrowingException.csproj index d705ebd65..6fede9c95 100644 --- a/TestAssets/NonRestoredTestProjects/AppThrowingException/App/AppThrowingException.csproj +++ b/TestAssets/NonRestoredTestProjects/AppThrowingException/App/AppThrowingException.csproj @@ -3,10 +3,9 @@ Exe - netcoreapp1.0 + netcoreapp1.1 dotnet-throwingtool $(AssemblyName) - $(CLI_SharedFrameworkVersion) diff --git a/TestAssets/NonRestoredTestProjects/AppThrowingException/AppDependingOnOtherAsTool/AppDependingOnOtherAsTool.csproj b/TestAssets/NonRestoredTestProjects/AppThrowingException/AppDependingOnOtherAsTool/AppDependingOnOtherAsTool.csproj index 7159443c2..30c6823e7 100644 --- a/TestAssets/NonRestoredTestProjects/AppThrowingException/AppDependingOnOtherAsTool/AppDependingOnOtherAsTool.csproj +++ b/TestAssets/NonRestoredTestProjects/AppThrowingException/AppDependingOnOtherAsTool/AppDependingOnOtherAsTool.csproj @@ -4,8 +4,6 @@ Exe netcoreapp2.0 - $(CLI_SharedFrameworkVersion) - netcoreapp2.0 diff --git a/TestAssets/NonRestoredTestProjects/AppWithNonExistingToolDependency/AppWithNonExistingToolDependency.csproj b/TestAssets/NonRestoredTestProjects/AppWithNonExistingToolDependency/AppWithNonExistingToolDependency.csproj index 11553b268..db9d6f117 100644 --- a/TestAssets/NonRestoredTestProjects/AppWithNonExistingToolDependency/AppWithNonExistingToolDependency.csproj +++ b/TestAssets/NonRestoredTestProjects/AppWithNonExistingToolDependency/AppWithNonExistingToolDependency.csproj @@ -4,7 +4,6 @@ Exe netcoreapp2.0 - $(CLI_SharedFrameworkVersion) diff --git a/TestAssets/NonRestoredTestProjects/ToolWithRandomPackageName/AppWithDepOnTool/AppWithDepOnTool.csproj b/TestAssets/NonRestoredTestProjects/ToolWithRandomPackageName/AppWithDepOnTool/AppWithDepOnTool.csproj index f62de8419..f5ab2f51a 100644 --- a/TestAssets/NonRestoredTestProjects/ToolWithRandomPackageName/AppWithDepOnTool/AppWithDepOnTool.csproj +++ b/TestAssets/NonRestoredTestProjects/ToolWithRandomPackageName/AppWithDepOnTool/AppWithDepOnTool.csproj @@ -5,8 +5,6 @@ Exe netcoreapp2.0 random-name - $(CLI_SharedFrameworkVersion) - netcoreapp2.0 diff --git a/TestAssets/NonRestoredTestProjects/ToolWithRandomPackageName/ToolWithRandomPackageName/ToolWithRandomPackageName.csproj b/TestAssets/NonRestoredTestProjects/ToolWithRandomPackageName/ToolWithRandomPackageName/ToolWithRandomPackageName.csproj index 3cbeb2a34..9184414e8 100644 --- a/TestAssets/NonRestoredTestProjects/ToolWithRandomPackageName/ToolWithRandomPackageName/ToolWithRandomPackageName.csproj +++ b/TestAssets/NonRestoredTestProjects/ToolWithRandomPackageName/ToolWithRandomPackageName/ToolWithRandomPackageName.csproj @@ -7,7 +7,6 @@ random-name $(GeneratedPackageId) dotnet-randompackage - $(CLI_SharedFrameworkVersion) diff --git a/TestAssets/TestPackages/ToolWithOutputName/ToolWithOutputName.csproj b/TestAssets/TestPackages/ToolWithOutputName/ToolWithOutputName.csproj index 4844d4232..6c57ebe5d 100644 --- a/TestAssets/TestPackages/ToolWithOutputName/ToolWithOutputName.csproj +++ b/TestAssets/TestPackages/ToolWithOutputName/ToolWithOutputName.csproj @@ -6,13 +6,6 @@ dotnet-tool-with-output-name ToolWithOutputName Exe - $(CLI_SharedFrameworkVersion) - - - $(ProjectRuntimeConfigFilePath) - - - diff --git a/TestAssets/TestPackages/dotnet-dependency-context-test/dotnet-dependency-context-test.csproj b/TestAssets/TestPackages/dotnet-dependency-context-test/dotnet-dependency-context-test.csproj index 1717cd460..97e20d00d 100644 --- a/TestAssets/TestPackages/dotnet-dependency-context-test/dotnet-dependency-context-test.csproj +++ b/TestAssets/TestPackages/dotnet-dependency-context-test/dotnet-dependency-context-test.csproj @@ -1,22 +1,12 @@  - + 1.0.0-rc - netcoreapp1.1 - dotnet-dependency-context-test + netcoreapp2.0 Exe - $(PackageTargetFallback);dnxcore50;portable-net45+win8 - 1.1.1 - false - - - $(ProjectRuntimeConfigFilePath) - - - diff --git a/TestAssets/TestPackages/dotnet-dependency-tool-invoker/dotnet-dependency-tool-invoker.csproj b/TestAssets/TestPackages/dotnet-dependency-tool-invoker/dotnet-dependency-tool-invoker.csproj index 23df5a2ee..47539b5f0 100644 --- a/TestAssets/TestPackages/dotnet-dependency-tool-invoker/dotnet-dependency-tool-invoker.csproj +++ b/TestAssets/TestPackages/dotnet-dependency-tool-invoker/dotnet-dependency-tool-invoker.csproj @@ -1,14 +1,14 @@  + + 1.0.0-rc - netcoreapp1.1 - dotnet-dependency-tool-invoker + netcoreapp2.0 Exe - $(PackageTargetFallback);portable-net45+win8;dnxcore50 - 1.1.1 false @@ -20,12 +20,6 @@ - - - $(ProjectRuntimeConfigFilePath) - - - diff --git a/TestAssets/TestPackages/dotnet-desktop-and-portable/dotnet-desktop-and-portable.csproj b/TestAssets/TestPackages/dotnet-desktop-and-portable/dotnet-desktop-and-portable.csproj index 1f3345bf4..185ef41f0 100644 --- a/TestAssets/TestPackages/dotnet-desktop-and-portable/dotnet-desktop-and-portable.csproj +++ b/TestAssets/TestPackages/dotnet-desktop-and-portable/dotnet-desktop-and-portable.csproj @@ -9,12 +9,6 @@ win7-x64;win7-x86 - - - $(ProjectRuntimeConfigFilePath) - - - 1.1.1 diff --git a/TestAssets/TestPackages/dotnet-fallbackfoldertool/dotnet-fallbackfoldertool.csproj b/TestAssets/TestPackages/dotnet-fallbackfoldertool/dotnet-fallbackfoldertool.csproj index b7049a0ca..35e92a2bb 100644 --- a/TestAssets/TestPackages/dotnet-fallbackfoldertool/dotnet-fallbackfoldertool.csproj +++ b/TestAssets/TestPackages/dotnet-fallbackfoldertool/dotnet-fallbackfoldertool.csproj @@ -6,12 +6,6 @@ dotnet-fallbackfoldertool Exe - $(CLI_SharedFrameworkVersion) - - - - $(ProjectRuntimeConfigFilePath) - - + diff --git a/TestAssets/TestPackages/dotnet-hello/v1/dotnet-hello/dotnet-hello.csproj b/TestAssets/TestPackages/dotnet-hello/v1/dotnet-hello/dotnet-hello.csproj index 8a5096465..fd5621f08 100644 --- a/TestAssets/TestPackages/dotnet-hello/v1/dotnet-hello/dotnet-hello.csproj +++ b/TestAssets/TestPackages/dotnet-hello/v1/dotnet-hello/dotnet-hello.csproj @@ -6,7 +6,6 @@ netcoreapp2.0 - $(CLI_SharedFrameworkVersion) dotnet-hello Exe win7-x64;win7-x86;osx.10.10-x64;osx.10.11-x64;ubuntu.14.04-x64;ubuntu.16.04-x64;ubuntu.16.10-x64;centos.7-x64;rhel.7.2-x64;debian.8-x64;fedora.24-x64;opensuse.42.1-x64 diff --git a/TestAssets/TestPackages/dotnet-hello/v2/dotnet-hello/dotnet-hello.csproj b/TestAssets/TestPackages/dotnet-hello/v2/dotnet-hello/dotnet-hello.csproj index 8f8164cef..2391dfc1b 100644 --- a/TestAssets/TestPackages/dotnet-hello/v2/dotnet-hello/dotnet-hello.csproj +++ b/TestAssets/TestPackages/dotnet-hello/v2/dotnet-hello/dotnet-hello.csproj @@ -6,7 +6,6 @@ netcoreapp2.0 - $(CLI_SharedFrameworkVersion) dotnet-hello Exe win7-x64;win7-x86;osx.10.10-x64;osx.10.11-x64;ubuntu.14.04-x64;ubuntu.16.04-x64;ubuntu.16.10-x64;centos.7-x64;rhel.7.2-x64;debian.8-x64;fedora.24-x64;opensuse.42.1-x64 diff --git a/TestAssets/TestPackages/dotnet-outputsframeworkversion/dotnet-outputsframeworkversion-netcoreapp1.0/dotnet-outputsframeworkversion-netcoreapp1.0.csproj b/TestAssets/TestPackages/dotnet-outputsframeworkversion/dotnet-outputsframeworkversion-netcoreapp1.0/dotnet-outputsframeworkversion-netcoreapp1.0.csproj index 17c0af923..e26afd464 100644 --- a/TestAssets/TestPackages/dotnet-outputsframeworkversion/dotnet-outputsframeworkversion-netcoreapp1.0/dotnet-outputsframeworkversion-netcoreapp1.0.csproj +++ b/TestAssets/TestPackages/dotnet-outputsframeworkversion/dotnet-outputsframeworkversion-netcoreapp1.0/dotnet-outputsframeworkversion-netcoreapp1.0.csproj @@ -7,9 +7,4 @@ Exe 1.1.1 - - - $(ProjectRuntimeConfigFilePath) - - diff --git a/TestAssets/TestPackages/dotnet-portable-v1-prefercli/dotnet-portable-v1-prefercli.csproj b/TestAssets/TestPackages/dotnet-portable-v1-prefercli/dotnet-portable-v1-prefercli.csproj new file mode 100644 index 000000000..10cc9b117 --- /dev/null +++ b/TestAssets/TestPackages/dotnet-portable-v1-prefercli/dotnet-portable-v1-prefercli.csproj @@ -0,0 +1,18 @@ + + + + + netcoreapp1.1 + Exe + + + + + $(ProjectRuntimeConfigFilePath) + + + + + + + diff --git a/TestAssets/TestPackages/dotnet-portable-v1/dotnet-portable-v1.csproj b/TestAssets/TestPackages/dotnet-portable-v1/dotnet-portable-v1.csproj new file mode 100644 index 000000000..b1bddfee9 --- /dev/null +++ b/TestAssets/TestPackages/dotnet-portable-v1/dotnet-portable-v1.csproj @@ -0,0 +1,12 @@ + + + + + netcoreapp1.1 + Exe + + + + + + diff --git a/TestAssets/TestPackages/dotnet-portable/Program.cs b/TestAssets/TestPackages/dotnet-portable/Program.cs index bcb5ed009..1c8fb26e7 100644 --- a/TestAssets/TestPackages/dotnet-portable/Program.cs +++ b/TestAssets/TestPackages/dotnet-portable/Program.cs @@ -2,6 +2,8 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; +using System.IO; +using System.Reflection; namespace ConsoleApplication { @@ -10,6 +12,20 @@ namespace ConsoleApplication public static void Main(string[] args) { Console.WriteLine("Hello Portable World!"); + + var depsFile = new FileInfo(GetDataFromAppDomain("FX_DEPS_FILE")); + string frameworkVersion = depsFile.Directory.Name; + + Console.WriteLine($"I'm running on shared framework version {frameworkVersion}!"); + } + + public static string GetDataFromAppDomain(string propertyName) + { + var appDomainType = typeof(object).GetTypeInfo().Assembly?.GetType("System.AppDomain"); + var currentDomain = appDomainType?.GetProperty("CurrentDomain")?.GetValue(null); + var deps = appDomainType?.GetMethod("GetData")?.Invoke(currentDomain, new[] { propertyName }); + + return deps as string; } } } diff --git a/TestAssets/TestPackages/dotnet-portable/dotnet-portable.csproj b/TestAssets/TestPackages/dotnet-portable/dotnet-portable.csproj index 6ec578ca4..bc2925f73 100644 --- a/TestAssets/TestPackages/dotnet-portable/dotnet-portable.csproj +++ b/TestAssets/TestPackages/dotnet-portable/dotnet-portable.csproj @@ -3,15 +3,7 @@ netcoreapp2.0 - dotnet-portable Exe - - $(CLI_SharedFrameworkVersion) - - - $(ProjectRuntimeConfigFilePath) - - diff --git a/TestAssets/TestPackages/dotnet-prefercliruntime/dotnet-prefercliruntime.csproj b/TestAssets/TestPackages/dotnet-prefercliruntime/dotnet-prefercliruntime.csproj index 9b9f2fec9..21eb0a6d1 100644 --- a/TestAssets/TestPackages/dotnet-prefercliruntime/dotnet-prefercliruntime.csproj +++ b/TestAssets/TestPackages/dotnet-prefercliruntime/dotnet-prefercliruntime.csproj @@ -5,14 +5,9 @@ netcoreapp2.0 Exe - $(CLI_SharedFrameworkVersion) - - $(ProjectRuntimeConfigFilePath) - - true \prefercliruntime diff --git a/TestAssets/TestProjects/AppWithDepOnToolWithOutputName/AppWithDepOnToolWithOutputName.csproj b/TestAssets/TestProjects/AppWithDepOnToolWithOutputName/AppWithDepOnToolWithOutputName.csproj index c1d0bb41a..9adf4c6fc 100755 --- a/TestAssets/TestProjects/AppWithDepOnToolWithOutputName/AppWithDepOnToolWithOutputName.csproj +++ b/TestAssets/TestProjects/AppWithDepOnToolWithOutputName/AppWithDepOnToolWithOutputName.csproj @@ -4,8 +4,6 @@ netcoreapp2.0 Exe - $(CLI_SharedFrameworkVersion) - netcoreapp2.0 diff --git a/TestAssets/TestProjects/AppWithDirectAndToolDep/AppWithDirectAndToolDep.csproj b/TestAssets/TestProjects/AppWithDirectAndToolDep/AppWithDirectAndToolDep.csproj index 8795839bc..df284421b 100755 --- a/TestAssets/TestProjects/AppWithDirectAndToolDep/AppWithDirectAndToolDep.csproj +++ b/TestAssets/TestProjects/AppWithDirectAndToolDep/AppWithDirectAndToolDep.csproj @@ -4,8 +4,6 @@ netcoreapp2.0 Exe - $(CLI_SharedFrameworkVersion) - netcoreapp2.0 diff --git a/TestAssets/TestProjects/AppWithDirectDep/AppWithDirectDep.csproj b/TestAssets/TestProjects/AppWithDirectDep/AppWithDirectDep.csproj index 0ca6ef86f..6995199ee 100755 --- a/TestAssets/TestProjects/AppWithDirectDep/AppWithDirectDep.csproj +++ b/TestAssets/TestProjects/AppWithDirectDep/AppWithDirectDep.csproj @@ -7,8 +7,6 @@ AppWithDirectDep Exe false - $(CLI_SharedFrameworkVersion) - netcoreapp2.0 diff --git a/TestAssets/TestProjects/AppWithDirectDepWithOutputName/AppWithDirectDepWithOutputName.csproj b/TestAssets/TestProjects/AppWithDirectDepWithOutputName/AppWithDirectDepWithOutputName.csproj index 4f189d465..5afb24921 100755 --- a/TestAssets/TestProjects/AppWithDirectDepWithOutputName/AppWithDirectDepWithOutputName.csproj +++ b/TestAssets/TestProjects/AppWithDirectDepWithOutputName/AppWithDirectDepWithOutputName.csproj @@ -4,8 +4,6 @@ netcoreapp2.0 Exe - $(CLI_SharedFrameworkVersion) - netcoreapp1.1 diff --git a/TestAssets/TestProjects/AppWithFallbackFolderToolDependency/AppWithFallbackFolderToolDependency.csproj b/TestAssets/TestProjects/AppWithFallbackFolderToolDependency/AppWithFallbackFolderToolDependency.csproj index 706240e90..705cf2077 100755 --- a/TestAssets/TestProjects/AppWithFallbackFolderToolDependency/AppWithFallbackFolderToolDependency.csproj +++ b/TestAssets/TestProjects/AppWithFallbackFolderToolDependency/AppWithFallbackFolderToolDependency.csproj @@ -4,8 +4,6 @@ netcoreapp2.0 Exe - $(CLI_SharedFrameworkVersion) - netcoreapp2.0 diff --git a/TestAssets/TestProjects/AppWithMultipleFxAndTools/MSBuildAppWithMultipleFrameworksAndTools.csproj b/TestAssets/TestProjects/AppWithMultipleFxAndTools/MSBuildAppWithMultipleFrameworksAndTools.csproj index db7004ecd..33cb2b5a7 100644 --- a/TestAssets/TestProjects/AppWithMultipleFxAndTools/MSBuildAppWithMultipleFrameworksAndTools.csproj +++ b/TestAssets/TestProjects/AppWithMultipleFxAndTools/MSBuildAppWithMultipleFrameworksAndTools.csproj @@ -4,7 +4,6 @@ Exe net451;netcoreapp2.0 - netcoreapp1.1 diff --git a/TestAssets/TestProjects/AppWithToolDependency/AppWithToolDependency.csproj b/TestAssets/TestProjects/AppWithToolDependency/AppWithToolDependency.csproj index f3506fae4..7f9c16848 100755 --- a/TestAssets/TestProjects/AppWithToolDependency/AppWithToolDependency.csproj +++ b/TestAssets/TestProjects/AppWithToolDependency/AppWithToolDependency.csproj @@ -4,8 +4,6 @@ netcoreapp2.0 Exe - $(CLI_SharedFrameworkVersion) - netcoreapp2.0 diff --git a/TestAssets/TestProjects/DependencyContextFromTool/DependencyContextFromTool.csproj b/TestAssets/TestProjects/DependencyContextFromTool/DependencyContextFromTool.csproj index 909f6aa9f..5dfd70f43 100755 --- a/TestAssets/TestProjects/DependencyContextFromTool/DependencyContextFromTool.csproj +++ b/TestAssets/TestProjects/DependencyContextFromTool/DependencyContextFromTool.csproj @@ -8,8 +8,6 @@ Exe false $(PackageTargetFallback);dnxcore50;portable-net45+win8 - $(CLI_SharedFrameworkVersion) - netcoreapp1.1 diff --git a/TestAssets/TestProjects/MSBuildAppWithMultipleFrameworks/MSBuildAppWithMultipleFrameworks.csproj b/TestAssets/TestProjects/MSBuildAppWithMultipleFrameworks/MSBuildAppWithMultipleFrameworks.csproj index 255d7f570..89aae6c65 100644 --- a/TestAssets/TestProjects/MSBuildAppWithMultipleFrameworks/MSBuildAppWithMultipleFrameworks.csproj +++ b/TestAssets/TestProjects/MSBuildAppWithMultipleFrameworks/MSBuildAppWithMultipleFrameworks.csproj @@ -4,7 +4,6 @@ Exe net451;netcoreapp2.0 - $(CLI_SharedFrameworkVersion) \ No newline at end of file diff --git a/TestAssets/TestProjects/MSBuildAppWithMultipleFrameworksAndTools/MSBuildAppWithMultipleFrameworksAndTools.csproj b/TestAssets/TestProjects/MSBuildAppWithMultipleFrameworksAndTools/MSBuildAppWithMultipleFrameworksAndTools.csproj index 5c26acade..766c1ae66 100644 --- a/TestAssets/TestProjects/MSBuildAppWithMultipleFrameworksAndTools/MSBuildAppWithMultipleFrameworksAndTools.csproj +++ b/TestAssets/TestProjects/MSBuildAppWithMultipleFrameworksAndTools/MSBuildAppWithMultipleFrameworksAndTools.csproj @@ -4,7 +4,6 @@ Exe net451;netcoreapp2.0 - netcoreapp1.1 diff --git a/TestAssets/TestProjects/MSBuildTestApp/MSBuildTestApp.csproj b/TestAssets/TestProjects/MSBuildTestApp/MSBuildTestApp.csproj index 1f9b629d4..79bceb82d 100644 --- a/TestAssets/TestProjects/MSBuildTestApp/MSBuildTestApp.csproj +++ b/TestAssets/TestProjects/MSBuildTestApp/MSBuildTestApp.csproj @@ -5,8 +5,6 @@ Exe netcoreapp2.0 win7-x64;win7-x86;osx.10.12-x64;ubuntu.14.04-x64;ubuntu.16.04-x64;ubuntu.16.10-x64;centos.7-x64;rhel.7-x64;debian.8-x64;fedora.24-x64;opensuse.42.1-x64 - $(CLI_SharedFrameworkVersion) - netcoreapp2.0 diff --git a/TestAssets/TestProjects/NuGetConfigDependentProject/NuGetConfigDependentProject.csproj b/TestAssets/TestProjects/NuGetConfigDependentProject/NuGetConfigDependentProject.csproj new file mode 100644 index 000000000..fd76d5489 --- /dev/null +++ b/TestAssets/TestProjects/NuGetConfigDependentProject/NuGetConfigDependentProject.csproj @@ -0,0 +1,11 @@ + + + + Exe + netcoreapp2.0 + + + + + + diff --git a/TestAssets/TestProjects/NuGetConfigDependentProject/Program.cs b/TestAssets/TestProjects/NuGetConfigDependentProject/Program.cs new file mode 100644 index 000000000..f6d539fe6 --- /dev/null +++ b/TestAssets/TestProjects/NuGetConfigDependentProject/Program.cs @@ -0,0 +1,16 @@ +// 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; +using System.Collections; +using NuGet.Configuration; + +class Program +{ + public static void Main(string[] args) + { + var settingValue = new SettingValue("key", "value", false); + + Console.WriteLine(settingValue.Key); + } +} diff --git a/TestAssets/TestProjects/NuGetConfigProfile/NuGetConfigFilterProfile.xml b/TestAssets/TestProjects/NuGetConfigProfile/NuGetConfigFilterProfile.xml new file mode 100644 index 000000000..cb238e3f0 --- /dev/null +++ b/TestAssets/TestProjects/NuGetConfigProfile/NuGetConfigFilterProfile.xml @@ -0,0 +1,3 @@ + + + diff --git a/TestAssets/TestProjects/NuGetConfigProfile/NuGetConfigProfile.xml b/TestAssets/TestProjects/NuGetConfigProfile/NuGetConfigProfile.xml new file mode 100644 index 000000000..da70b1394 --- /dev/null +++ b/TestAssets/TestProjects/NuGetConfigProfile/NuGetConfigProfile.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/TestAssets/TestProjects/TestAppSimple/TestAppSimple.csproj b/TestAssets/TestProjects/TestAppSimple/TestAppSimple.csproj index 4f0d4e8e5..302abe3bc 100755 --- a/TestAssets/TestProjects/TestAppSimple/TestAppSimple.csproj +++ b/TestAssets/TestProjects/TestAppSimple/TestAppSimple.csproj @@ -4,7 +4,6 @@ netcoreapp2.0 Exe - $(CLI_SharedFrameworkVersion) true diff --git a/TestAssets/TestProjects/TestAppWithProjDepTool/TestAppWithProjDepTool.csproj b/TestAssets/TestProjects/TestAppWithProjDepTool/TestAppWithProjDepTool.csproj index bedcf3da2..3f8176791 100644 --- a/TestAssets/TestProjects/TestAppWithProjDepTool/TestAppWithProjDepTool.csproj +++ b/TestAssets/TestProjects/TestAppWithProjDepTool/TestAppWithProjDepTool.csproj @@ -4,8 +4,6 @@ Exe netcoreapp2.0 - $(CLI_SharedFrameworkVersion) - netcoreapp1.1 diff --git a/TestAssets/TestProjects/VSTestDotNetCore/Tests.cs b/TestAssets/TestProjects/VSTestCore/Tests.cs similarity index 100% rename from TestAssets/TestProjects/VSTestDotNetCore/Tests.cs rename to TestAssets/TestProjects/VSTestCore/Tests.cs diff --git a/TestAssets/TestProjects/VSTestDotNetCore/VSTestDotNetCore.csproj b/TestAssets/TestProjects/VSTestCore/VSTestCore.csproj similarity index 88% rename from TestAssets/TestProjects/VSTestDotNetCore/VSTestDotNetCore.csproj rename to TestAssets/TestProjects/VSTestCore/VSTestCore.csproj index 711143c68..0d07738af 100644 --- a/TestAssets/TestProjects/VSTestDotNetCore/VSTestDotNetCore.csproj +++ b/TestAssets/TestProjects/VSTestCore/VSTestCore.csproj @@ -4,7 +4,6 @@ Exe netcoreapp2.0 - $(CLI_SharedFrameworkVersion) diff --git a/TestAssets/TestProjects/VSTestDesktopAndNetCore/Tests.cs b/TestAssets/TestProjects/VSTestMulti/Tests.cs similarity index 100% rename from TestAssets/TestProjects/VSTestDesktopAndNetCore/Tests.cs rename to TestAssets/TestProjects/VSTestMulti/Tests.cs diff --git a/TestAssets/TestProjects/VSTestDesktopAndNetCore/VSTestDesktopAndNetCore.csproj b/TestAssets/TestProjects/VSTestMulti/VSTestDesktopAndNetCore.csproj similarity index 79% rename from TestAssets/TestProjects/VSTestDesktopAndNetCore/VSTestDesktopAndNetCore.csproj rename to TestAssets/TestProjects/VSTestMulti/VSTestDesktopAndNetCore.csproj index 84252d545..1a8fb8e53 100644 --- a/TestAssets/TestProjects/VSTestDesktopAndNetCore/VSTestDesktopAndNetCore.csproj +++ b/TestAssets/TestProjects/VSTestMulti/VSTestDesktopAndNetCore.csproj @@ -2,7 +2,6 @@ - Exe net46;netcoreapp2.0 @@ -10,10 +9,6 @@ DESKTOP;$(DefineConstants) - - $(CLI_SharedFrameworkVersion) - - diff --git a/TestAssets/TestProjects/VSTestXunitDotNetCore/UnitTest1.cs b/TestAssets/TestProjects/XunitCore/UnitTest1.cs similarity index 100% rename from TestAssets/TestProjects/VSTestXunitDotNetCore/UnitTest1.cs rename to TestAssets/TestProjects/XunitCore/UnitTest1.cs diff --git a/TestAssets/TestProjects/VSTestXunitDotNetCore/VSTestXunitDotNetCore.csproj b/TestAssets/TestProjects/XunitCore/XunitCore.csproj similarity index 88% rename from TestAssets/TestProjects/VSTestXunitDotNetCore/VSTestXunitDotNetCore.csproj rename to TestAssets/TestProjects/XunitCore/XunitCore.csproj index ae4226e6c..d6016beea 100644 --- a/TestAssets/TestProjects/VSTestXunitDotNetCore/VSTestXunitDotNetCore.csproj +++ b/TestAssets/TestProjects/XunitCore/XunitCore.csproj @@ -4,7 +4,6 @@ Exe netcoreapp2.0 - $(CLI_SharedFrameworkVersion) diff --git a/TestAssets/TestProjects/VSTestXunitDesktopAndNetCore/UnitTest1.cs b/TestAssets/TestProjects/XunitMulti/UnitTest1.cs similarity index 100% rename from TestAssets/TestProjects/VSTestXunitDesktopAndNetCore/UnitTest1.cs rename to TestAssets/TestProjects/XunitMulti/UnitTest1.cs diff --git a/TestAssets/TestProjects/VSTestXunitDesktopAndNetCore/VSTestXunitDesktopAndNetCore.csproj b/TestAssets/TestProjects/XunitMulti/VSTestXunitDesktopAndNetCore.csproj similarity index 100% rename from TestAssets/TestProjects/VSTestXunitDesktopAndNetCore/VSTestXunitDesktopAndNetCore.csproj rename to TestAssets/TestProjects/XunitMulti/VSTestXunitDesktopAndNetCore.csproj diff --git a/build/BackwardsCompatibilityRuntimes.props b/build/BackwardsCompatibilityRuntimes.props index 5cadcb052..6805d4377 100644 --- a/build/BackwardsCompatibilityRuntimes.props +++ b/build/BackwardsCompatibilityRuntimes.props @@ -20,7 +20,7 @@ $(BackwardsCompatibility110CoreSetupBlobRootUrlWithChannel)/Binaries/$(BackwardsCompatibility110SharedFrameworkVersion) $(BackwardsCompatibility110CoreSetupBlobRootUrlWithChannel)/Installers $(IntermediateDirectory)/coreSetupDownload/$(BackwardsCompatibility110SharedFrameworkVersion) - $(BackwardsCompatibility110CoreSetupDownloadDirectory)/combinedSharedHostAndFrameworkArchive + $(BackwardsCompatibility110CoreSetupDownloadDirectory)/combinedSharedHostAndFrameworkArchive$(ArchiveExtension) diff --git a/build/BundledRuntimes.props b/build/BundledRuntimes.props index 0821f4f2c..9179f91da 100644 --- a/build/BundledRuntimes.props +++ b/build/BundledRuntimes.props @@ -27,7 +27,22 @@ $(CoreSetupBlobRootUrlWithChannel)/Binaries/$(SharedFrameworkVersion) $(CoreSetupBlobRootUrlWithChannel)/Installers $(IntermediateDirectory)/coreSetupDownload/$(SharedFrameworkVersion) - $(CoreSetupDownloadDirectory)/combinedSharedHostAndFrameworkArchive + $(CoreSetupDownloadDirectory)/combinedSharedHostAndFrameworkArchive$(ArchiveExtension) + + + + $(CoreSetupBlobRootUrl)aspnetcore/store/$(AspNetCoreRuntimeVersion) + + + $(OSName)$(Architecture) + $(OSName) + linux + + Build.RS.$(AspNetCoreRuntimeInstallerArchiveFileNameOSToken)$(ArchiveExtension) + $(PackagesDirectory)/$(AspNetCoreRuntimeInstallerArchiveFileName) + + AspNetCorePackageStoreLib$(Architecture).wixlib + $(PackagesDirectory)/$(AspNetCoreRuntimeInstallerWixLibFileName) @@ -49,14 +64,29 @@ Condition="'$(SkipBuildingInstallers)' != 'true' And !Exists('$(DownloadedSharedHostInstallerFile)') And '$(InstallerExtension)' != ''"> $(CoreSetupInstallerBlobRootUrl)/$(SharedHostVersion)/$(DownloadedSharedHostInstallerFileName) $(DownloadedSharedHostInstallerFile) - + <_DownloadAndExtractItem Include="DownloadedHostFxrInstallerFile" Condition="'$(SkipBuildingInstallers)' != 'true' And !Exists('$(DownloadedHostFxrInstallerFile)') And '$(InstallerExtension)' != ''"> $(CoreSetupInstallerBlobRootUrl)/$(HostFxrVersion)/$(DownloadedHostFxrInstallerFileName) $(DownloadedHostFxrInstallerFile) - + + + <_DownloadAndExtractItem Include="AspNetCoreRuntimeInstallerWixLibFile" + Condition=" '$(AspNetCoreRuntimeInstallerWixLibFile)' != '' And !Exists('$(AspNetCoreRuntimeInstallerWixLibFile)')"> + $(AspNetCoreRuntimeInstallerBlobRootUrl)/$(AspNetCoreRuntimeInstallerWixLibFileName) + $(AspNetCoreRuntimeInstallerWixLibFile) + + + + <_DownloadAndExtractItem Include="AspNetCoreRuntimeInstallerArchiveFile" + Condition="!Exists('$(AspNetCoreRuntimeInstallerArchiveFile)')"> + $(AspNetCoreRuntimeInstallerBlobRootUrl)/$(AspNetCoreRuntimeInstallerArchiveFileName) + $(AspNetCoreRuntimeInstallerArchiveFile) + $(AspNetRuntimePackageStorePublishDirectory) + + diff --git a/build/Compile.targets b/build/Compile.targets index b2ebb2ebc..d2a3747aa 100644 --- a/build/Compile.targets +++ b/build/Compile.targets @@ -12,5 +12,14 @@ + + + + + + diff --git a/build/DependencyVersions.props b/build/DependencyVersions.props index 54fda00c4..7383f1fda 100644 --- a/build/DependencyVersions.props +++ b/build/DependencyVersions.props @@ -2,22 +2,25 @@ 2.0.0-preview2-002093-00 - 15.2.0-preview-000093-02 + 15.3.0-preview-000117-01 2.0.0-rc4-61325-08 2.0.0-preview2-20170425-7 4.3.0-preview1-2500 - 1.0.0-rel-20170413-451 - 15.1.0-preview-20170414-04 + 1.0.0-rel-20170501-473 + 15.3.0-preview-20170502-03 $(CLI_SharedFrameworkVersion) $(CLI_SharedFrameworkVersion) $(CLI_SharedFrameworkVersion) - 1.0.0-beta2-20170425-201 - 1.0.0-beta2-20170425-203 - 1.0.0-beta2-20170425-203 + 1.0.0-beta2-20170503-217 + 1.0.0-beta2-20170504-221 + 1.0.0-beta2-20170504-221 2.0.0-preview2-002093 2.0.0-preview2-002093 0.1.0-alpha-142 - 1.2.1-alpha-002130 + 2.0.0-preview1-65 + + + notimestamp diff --git a/build/MSBuildExtensions.targets b/build/MSBuildExtensions.targets index 9b99b96b9..b8d2d97e9 100644 --- a/build/MSBuildExtensions.targets +++ b/build/MSBuildExtensions.targets @@ -9,7 +9,6 @@ - 15.0/Imports/Microsoft.Common.props/ImportBefore Microsoft.NETCoreSdk.BundledVersions.props @@ -59,12 +58,9 @@ Copyright (c) .NET Foundation. All rights reserved. - - + - diff --git a/build/OutputDirectories.props b/build/OutputDirectories.props index 99a5666cf..f780e3656 100644 --- a/build/OutputDirectories.props +++ b/build/OutputDirectories.props @@ -10,9 +10,12 @@ $(BaseOutputDirectory)/intermediate $(BaseOutputDirectory)/packages $(IntermediateDirectory)/sharedFrameworkPublish + + $(BaseOutputDirectory)/AspRT $(IntermediateDirectory)/backwardsCompatibleSharedFrameworksPublish $(RepoRoot)/artifacts/testpackages/ $(OutputDirectory)/dotnet$(ExeExtension) $(IntermediateDirectory)/GeneratedMSBuildExtensions + $(IntermediateDirectory)/MSBuildSdkResolver diff --git a/build/Prepare.targets b/build/Prepare.targets index d875e2b8b..074f4b758 100644 --- a/build/Prepare.targets +++ b/build/Prepare.targets @@ -36,12 +36,12 @@ Uri="%(_DownloadAndExtractItem.Url)" DestinationPath="%(_DownloadAndExtractItem.DownloadFileName)" /> - - diff --git a/build/Signing.proj b/build/Signing.proj index 267f0c975..3fa6d63b4 100644 --- a/build/Signing.proj +++ b/build/Signing.proj @@ -18,6 +18,7 @@ $(BaseOutputDirectory)/stage2 $(BaseOutputDirectory)/stage2compilation $(BaseOutputDirectory)/packages + $(BaseOutputDirectory)/intermediate/MSBuildSdkResolver @@ -71,6 +72,19 @@ + + + + + $(SdkResolverOutputDirectory) + + + + $(InternalCertificateId) + + + + diff --git a/build/compile/LzmaArchive.targets b/build/compile/LzmaArchive.targets index ae7bf4646..98a23337b 100644 --- a/build/compile/LzmaArchive.targets +++ b/build/compile/LzmaArchive.targets @@ -2,127 +2,20 @@ - false - - <configuration> - <packageSources> - <add key="configurable.source" value="%CLI_LZMA_PACKAGE_SOURCE%" /> - </packageSources> - </configuration> - - - $(IntermediateDirectory)/NuGetPackagesArchiveProject - $(IntermediateDirectory)/NuGetPackagesArchiveFolder - $(NuGetPackagesArchiveProject)/Nuget.config - $(RepoRoot)/NuGet.Config - $(BaseOutputDirectory)/tools - $(ToolsOutputDirectory)/Archiver.dll $(SdkOutputDirectory)/nuGetPackagesArchive.lzma + nuGetPackagesArchive.$(AspNetCoreRuntimePackageFlavor).lzma + $(IntermediateDirectory)/$(NugetPackagesArchiveName) + $(AspNetCoreRuntimeInstallerBlobRootUrl)/$(NugetPackagesArchiveName) - - - - - - - - - - - $(NugetPackagesArchiveRelativeBlobUrl)/$([System.String]::Copy('%(Filename)%(Extension)').Replace('\' ,'/')) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - nuGetPackagesArchive.$(NuGetPackagesArchiveVersion).lzma - $(IntermediateDirectory)/$(NugetPackagesArchiveName) - $(Product)/NuGetPackagesArchives - $(DotnetBlobRootUrl)/$(NugetPackagesArchiveRelativeBlobUrl)/$(NugetPackagesArchiveName) - + diff --git a/build/package/Installer.DEB.proj b/build/package/Installer.DEB.proj index f151ba1e5..80aefcc73 100644 --- a/build/package/Installer.DEB.proj +++ b/build/package/Installer.DEB.proj @@ -10,7 +10,7 @@ TestDebuild; BuildSdkDeb; TestSdkDeb;" - Condition=" '$(OSName)' == 'ubuntu' " + Condition=" '$(OSName)' == 'ubuntu' " Outputs="@(GeneratedInstallers)"/> - + + + + + + + - @@ -58,12 +74,12 @@ PackageName="$(SdkDebianPackageName)" PackageVersion="$(SdkVersion)" WorkingDirectory="$(DotnetDebToolDir)" /> - + - + - - + + @@ -158,11 +174,11 @@ - + - + diff --git a/build/package/Installer.DEB.targets b/build/package/Installer.DEB.targets index 1a041fe20..c4f0d1797 100644 --- a/build/package/Installer.DEB.targets +++ b/build/package/Installer.DEB.targets @@ -75,6 +75,11 @@ $(LayoutDirectory)/debian_config.json + + $(RepoRoot)/packaging/deb/postinst + $(LayoutDirectory)/debian/postinst + + $(SharedFxDebianPackageName) diff --git a/build/package/Installer.MSI.targets b/build/package/Installer.MSI.targets index 86e81c22b..c11174f2d 100644 --- a/build/package/Installer.MSI.targets +++ b/build/package/Installer.MSI.targets @@ -115,6 +115,7 @@ diff --git a/build/package/Installer.PKG.targets b/build/package/Installer.PKG.targets index a4ad4600f..53a794905 100644 --- a/build/package/Installer.PKG.targets +++ b/build/package/Installer.PKG.targets @@ -80,6 +80,9 @@ DependsOnTargets="Init;Layout;SetupPkgInputsOutputs" Condition=" '$(OSName)' == 'osx' "> + + + + + + True + + dotnet-portable + dotnet-portable-v1.csproj + True + True + 1.0.0 + + True + + + dotnet-portable + dotnet-portable-v1-prefercli.csproj + True + True + 1.0.0 + + True + dotnet-fallbackfoldertool dotnet-fallbackfoldertool.csproj diff --git a/build_projects/update-dependencies/Config.cs b/build_projects/update-dependencies/Config.cs index e9c08ac10..9938cce68 100644 --- a/build_projects/update-dependencies/Config.cs +++ b/build_projects/update-dependencies/Config.cs @@ -2,6 +2,9 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; +using System.IO; +using System.Linq; +using System.Xml.Linq; namespace Microsoft.DotNet.Scripts { @@ -35,11 +38,10 @@ namespace Microsoft.DotNet.Scripts private Lazy _password = new Lazy(() => GetEnvironmentVariable("GITHUB_PASSWORD")); private Lazy _dotNetVersionUrl = new Lazy(() => GetEnvironmentVariable("DOTNET_VERSION_URL", "https://raw.githubusercontent.com/dotnet/versions/master/build-info")); - private Lazy _roslynVersionFragment = new Lazy(() => GetEnvironmentVariable("ROSLYN_VERSION_FRAGMENT", "dotnet/roslyn/netcore1.0")); - private Lazy _coreSetupVersionFragment = new Lazy(() => GetEnvironmentVariable("CORESETUP_VERSION_FRAGMENT", "dotnet/core-setup/master")); + private Lazy _coreSetupVersionFragment = new Lazy(() => GetEnvironmentVariable("CORESETUP_VERSION_FRAGMENT", GetDefaultCoreSetupVersionFragment())); private Lazy _gitHubUpstreamOwner = new Lazy(() => GetEnvironmentVariable("GITHUB_UPSTREAM_OWNER", "dotnet")); private Lazy _gitHubProject = new Lazy(() => GetEnvironmentVariable("GITHUB_PROJECT", "cli")); - private Lazy _gitHubUpstreamBranch = new Lazy(() => GetEnvironmentVariable("GITHUB_UPSTREAM_BRANCH", "master")); + private Lazy _gitHubUpstreamBranch = new Lazy(() => GetEnvironmentVariable("GITHUB_UPSTREAM_BRANCH", GetDefaultUpstreamBranch())); private Lazy _gitHubPullRequestNotifications = new Lazy(() => GetEnvironmentVariable("GITHUB_PULL_REQUEST_NOTIFICATIONS", "") .Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)); @@ -51,7 +53,6 @@ namespace Microsoft.DotNet.Scripts public string Email => _email.Value; public string Password => _password.Value; public string DotNetVersionUrl => _dotNetVersionUrl.Value; - public string RoslynVersionFragment => _roslynVersionFragment.Value; public string CoreSetupVersionFragment => _coreSetupVersionFragment.Value; public string GitHubUpstreamOwner => _gitHubUpstreamOwner.Value; public string GitHubProject => _gitHubProject.Value; @@ -73,5 +74,38 @@ namespace Microsoft.DotNet.Scripts return value; } + + private static string GetDefaultUpstreamBranch() + { + return GetRepoMSBuildPropValue("BranchInfo.props", "BranchName") ?? "master"; + } + + private static string GetDefaultCoreSetupVersionFragment() + { + string coreSetupChannel = GetRepoMSBuildPropValue("BundledRuntimes.props", "CoreSetupChannel") ?? "master"; + + return $"dotnet/core-setup/{coreSetupChannel}"; + } + + private static string GetRepoMSBuildPropValue(string propsFileName, string propertyName) + { + var propsFilePath = Path.Combine(Dirs.RepoRoot, "build", propsFileName); + var root = XDocument.Load(propsFilePath).Root; + var ns = root.Name.Namespace; + + var value = root + .Elements(ns + "PropertyGroup") + .Elements(ns + propertyName) + .FirstOrDefault() + ?.Value; + + if (string.IsNullOrEmpty(value)) + { + Console.WriteLine($"Could not find a property named '{propertyName}' in {propsFilePath}"); + return null; + } + + return value; + } } } diff --git a/build_projects/update-dependencies/Program.cs b/build_projects/update-dependencies/Program.cs index 6da45dc9a..296ad2d0a 100644 --- a/build_projects/update-dependencies/Program.cs +++ b/build_projects/update-dependencies/Program.cs @@ -25,7 +25,6 @@ namespace Microsoft.DotNet.Scripts List buildInfos = new List(); - buildInfos.Add(GetBuildInfo("Roslyn", s_config.RoslynVersionFragment, fetchLatestReleaseFile: false)); buildInfos.Add(GetBuildInfo("CoreSetup", s_config.CoreSetupVersionFragment, fetchLatestReleaseFile: false)); IEnumerable updaters = GetUpdaters(); diff --git a/packaging/deb/postinst b/packaging/deb/postinst old mode 100644 new mode 100755 index b000f5933..aac8be85c --- a/packaging/deb/postinst +++ b/packaging/deb/postinst @@ -1,3 +1,15 @@ #!/usr/bin/env sh echo "This software may collect information about you and your use of the software, and send that to Microsoft." echo "Please visit http://aka.ms/dotnet-cli-eula for more information." + +# Run 'dotnet new' as the user to trigger the first time experience to initialize the cache +echo "Welcome to .NET Core! +--------------------- +Learn more about .NET Core @ https://aka.ms/dotnet-docs. Use dotnet --help to see available commands or go to https://aka.ms/dotnet-cli-docs. + +Telemetry +-------------- +The .NET Core tools collect usage data in order to improve your experience. The data is anonymous and does not include command-line arguments. The data is collected by Microsoft and shared with the community. +You can opt out of telemetry by setting a DOTNET_CLI_TELEMETRY_OPTOUT environment variable to 1 using your favorite shell. +You can read more about .NET Core tools telemetry @ https://aka.ms/dotnet-cli-telemetry." +su - $SUDO_USER -c "dotnet new > /dev/null 2>&1 || true" diff --git a/packaging/osx/clisdk/Distribution-Template b/packaging/osx/clisdk/Distribution-Template index 5d4390ac3..e4cb89bc4 100644 --- a/packaging/osx/clisdk/Distribution-Template +++ b/packaging/osx/clisdk/Distribution-Template @@ -5,13 +5,12 @@ + - + - - @@ -24,7 +23,7 @@ - + @@ -34,4 +33,4 @@ {HostFxrComponentId}.pkg {SharedHostComponentId}.pkg {CLISdkComponentId}.pkg - + \ No newline at end of file diff --git a/packaging/osx/clisdk/resources/cs.lproj/firstTimeWelcomeMessage.html b/packaging/osx/clisdk/resources/cs.lproj/firstTimeWelcomeMessage.html new file mode 100644 index 000000000..af9179267 --- /dev/null +++ b/packaging/osx/clisdk/resources/cs.lproj/firstTimeWelcomeMessage.html @@ -0,0 +1,29 @@ + + + + + Welcome to .NET Core! + + + +

+ Welcome to .NET Core! +

+

+ Learn more about .NET Core at https://aka.ms/dotnet-docs . Use dotnet --help to see available commands or go to https://aka.ms/dotnet-cli-docs. +

+

+ Telemetry +

+

+ The .NET Core tools collect usage data in order to improve your experience. The data is anonymous and does not include command-line arguments. The data is collected by Microsoft and shared with the community. You can opt out of telemetry by setting a DOTNET_CLI_TELEMETRY_OPTOUT environment variable to 1 using your favorite shell. You can read more about .NET Core tools telemetry at https://aka.ms/dotnet-cli-telemetry. +

+

+ Configuration +

+

+ A command is run in the end of install process to initially populate your local package cache, to improve restore speed and enable offline access. This command will take up to a minute to complete and will only happen once. +

+
+ + \ No newline at end of file diff --git a/packaging/osx/clisdk/resources/de.lproj/firstTimeWelcomeMessage.html b/packaging/osx/clisdk/resources/de.lproj/firstTimeWelcomeMessage.html new file mode 100644 index 000000000..af9179267 --- /dev/null +++ b/packaging/osx/clisdk/resources/de.lproj/firstTimeWelcomeMessage.html @@ -0,0 +1,29 @@ + + + + + Welcome to .NET Core! + + + +

+ Welcome to .NET Core! +

+

+ Learn more about .NET Core at https://aka.ms/dotnet-docs . Use dotnet --help to see available commands or go to https://aka.ms/dotnet-cli-docs. +

+

+ Telemetry +

+

+ The .NET Core tools collect usage data in order to improve your experience. The data is anonymous and does not include command-line arguments. The data is collected by Microsoft and shared with the community. You can opt out of telemetry by setting a DOTNET_CLI_TELEMETRY_OPTOUT environment variable to 1 using your favorite shell. You can read more about .NET Core tools telemetry at https://aka.ms/dotnet-cli-telemetry. +

+

+ Configuration +

+

+ A command is run in the end of install process to initially populate your local package cache, to improve restore speed and enable offline access. This command will take up to a minute to complete and will only happen once. +

+
+ + \ No newline at end of file diff --git a/packaging/osx/clisdk/resources/en.lproj/firstTimeWelcomeMessage.html b/packaging/osx/clisdk/resources/en.lproj/firstTimeWelcomeMessage.html new file mode 100644 index 000000000..af9179267 --- /dev/null +++ b/packaging/osx/clisdk/resources/en.lproj/firstTimeWelcomeMessage.html @@ -0,0 +1,29 @@ + + + + + Welcome to .NET Core! + + + +

+ Welcome to .NET Core! +

+

+ Learn more about .NET Core at https://aka.ms/dotnet-docs . Use dotnet --help to see available commands or go to https://aka.ms/dotnet-cli-docs. +

+

+ Telemetry +

+

+ The .NET Core tools collect usage data in order to improve your experience. The data is anonymous and does not include command-line arguments. The data is collected by Microsoft and shared with the community. You can opt out of telemetry by setting a DOTNET_CLI_TELEMETRY_OPTOUT environment variable to 1 using your favorite shell. You can read more about .NET Core tools telemetry at https://aka.ms/dotnet-cli-telemetry. +

+

+ Configuration +

+

+ A command is run in the end of install process to initially populate your local package cache, to improve restore speed and enable offline access. This command will take up to a minute to complete and will only happen once. +

+
+ + \ No newline at end of file diff --git a/packaging/osx/clisdk/resources/es.lproj/firstTimeWelcomeMessage.html b/packaging/osx/clisdk/resources/es.lproj/firstTimeWelcomeMessage.html new file mode 100644 index 000000000..af9179267 --- /dev/null +++ b/packaging/osx/clisdk/resources/es.lproj/firstTimeWelcomeMessage.html @@ -0,0 +1,29 @@ + + + + + Welcome to .NET Core! + + + +

+ Welcome to .NET Core! +

+

+ Learn more about .NET Core at https://aka.ms/dotnet-docs . Use dotnet --help to see available commands or go to https://aka.ms/dotnet-cli-docs. +

+

+ Telemetry +

+

+ The .NET Core tools collect usage data in order to improve your experience. The data is anonymous and does not include command-line arguments. The data is collected by Microsoft and shared with the community. You can opt out of telemetry by setting a DOTNET_CLI_TELEMETRY_OPTOUT environment variable to 1 using your favorite shell. You can read more about .NET Core tools telemetry at https://aka.ms/dotnet-cli-telemetry. +

+

+ Configuration +

+

+ A command is run in the end of install process to initially populate your local package cache, to improve restore speed and enable offline access. This command will take up to a minute to complete and will only happen once. +

+
+ + \ No newline at end of file diff --git a/packaging/osx/clisdk/resources/fr.lproj/firstTimeWelcomeMessage.html b/packaging/osx/clisdk/resources/fr.lproj/firstTimeWelcomeMessage.html new file mode 100644 index 000000000..af9179267 --- /dev/null +++ b/packaging/osx/clisdk/resources/fr.lproj/firstTimeWelcomeMessage.html @@ -0,0 +1,29 @@ + + + + + Welcome to .NET Core! + + + +

+ Welcome to .NET Core! +

+

+ Learn more about .NET Core at https://aka.ms/dotnet-docs . Use dotnet --help to see available commands or go to https://aka.ms/dotnet-cli-docs. +

+

+ Telemetry +

+

+ The .NET Core tools collect usage data in order to improve your experience. The data is anonymous and does not include command-line arguments. The data is collected by Microsoft and shared with the community. You can opt out of telemetry by setting a DOTNET_CLI_TELEMETRY_OPTOUT environment variable to 1 using your favorite shell. You can read more about .NET Core tools telemetry at https://aka.ms/dotnet-cli-telemetry. +

+

+ Configuration +

+

+ A command is run in the end of install process to initially populate your local package cache, to improve restore speed and enable offline access. This command will take up to a minute to complete and will only happen once. +

+
+ + \ No newline at end of file diff --git a/packaging/osx/clisdk/resources/it.lproj/firstTimeWelcomeMessage.html b/packaging/osx/clisdk/resources/it.lproj/firstTimeWelcomeMessage.html new file mode 100644 index 000000000..af9179267 --- /dev/null +++ b/packaging/osx/clisdk/resources/it.lproj/firstTimeWelcomeMessage.html @@ -0,0 +1,29 @@ + + + + + Welcome to .NET Core! + + + +

+ Welcome to .NET Core! +

+

+ Learn more about .NET Core at https://aka.ms/dotnet-docs . Use dotnet --help to see available commands or go to https://aka.ms/dotnet-cli-docs. +

+

+ Telemetry +

+

+ The .NET Core tools collect usage data in order to improve your experience. The data is anonymous and does not include command-line arguments. The data is collected by Microsoft and shared with the community. You can opt out of telemetry by setting a DOTNET_CLI_TELEMETRY_OPTOUT environment variable to 1 using your favorite shell. You can read more about .NET Core tools telemetry at https://aka.ms/dotnet-cli-telemetry. +

+

+ Configuration +

+

+ A command is run in the end of install process to initially populate your local package cache, to improve restore speed and enable offline access. This command will take up to a minute to complete and will only happen once. +

+
+ + \ No newline at end of file diff --git a/packaging/osx/clisdk/resources/ja.lproj/firstTimeWelcomeMessage.html b/packaging/osx/clisdk/resources/ja.lproj/firstTimeWelcomeMessage.html new file mode 100644 index 000000000..af9179267 --- /dev/null +++ b/packaging/osx/clisdk/resources/ja.lproj/firstTimeWelcomeMessage.html @@ -0,0 +1,29 @@ + + + + + Welcome to .NET Core! + + + +

+ Welcome to .NET Core! +

+

+ Learn more about .NET Core at https://aka.ms/dotnet-docs . Use dotnet --help to see available commands or go to https://aka.ms/dotnet-cli-docs. +

+

+ Telemetry +

+

+ The .NET Core tools collect usage data in order to improve your experience. The data is anonymous and does not include command-line arguments. The data is collected by Microsoft and shared with the community. You can opt out of telemetry by setting a DOTNET_CLI_TELEMETRY_OPTOUT environment variable to 1 using your favorite shell. You can read more about .NET Core tools telemetry at https://aka.ms/dotnet-cli-telemetry. +

+

+ Configuration +

+

+ A command is run in the end of install process to initially populate your local package cache, to improve restore speed and enable offline access. This command will take up to a minute to complete and will only happen once. +

+
+ + \ No newline at end of file diff --git a/packaging/osx/clisdk/resources/ko.lproj/firstTimeWelcomeMessage.html b/packaging/osx/clisdk/resources/ko.lproj/firstTimeWelcomeMessage.html new file mode 100644 index 000000000..af9179267 --- /dev/null +++ b/packaging/osx/clisdk/resources/ko.lproj/firstTimeWelcomeMessage.html @@ -0,0 +1,29 @@ + + + + + Welcome to .NET Core! + + + +

+ Welcome to .NET Core! +

+

+ Learn more about .NET Core at https://aka.ms/dotnet-docs . Use dotnet --help to see available commands or go to https://aka.ms/dotnet-cli-docs. +

+

+ Telemetry +

+

+ The .NET Core tools collect usage data in order to improve your experience. The data is anonymous and does not include command-line arguments. The data is collected by Microsoft and shared with the community. You can opt out of telemetry by setting a DOTNET_CLI_TELEMETRY_OPTOUT environment variable to 1 using your favorite shell. You can read more about .NET Core tools telemetry at https://aka.ms/dotnet-cli-telemetry. +

+

+ Configuration +

+

+ A command is run in the end of install process to initially populate your local package cache, to improve restore speed and enable offline access. This command will take up to a minute to complete and will only happen once. +

+
+ + \ No newline at end of file diff --git a/packaging/osx/clisdk/resources/pl.lproj/firstTimeWelcomeMessage.html b/packaging/osx/clisdk/resources/pl.lproj/firstTimeWelcomeMessage.html new file mode 100644 index 000000000..af9179267 --- /dev/null +++ b/packaging/osx/clisdk/resources/pl.lproj/firstTimeWelcomeMessage.html @@ -0,0 +1,29 @@ + + + + + Welcome to .NET Core! + + + +

+ Welcome to .NET Core! +

+

+ Learn more about .NET Core at https://aka.ms/dotnet-docs . Use dotnet --help to see available commands or go to https://aka.ms/dotnet-cli-docs. +

+

+ Telemetry +

+

+ The .NET Core tools collect usage data in order to improve your experience. The data is anonymous and does not include command-line arguments. The data is collected by Microsoft and shared with the community. You can opt out of telemetry by setting a DOTNET_CLI_TELEMETRY_OPTOUT environment variable to 1 using your favorite shell. You can read more about .NET Core tools telemetry at https://aka.ms/dotnet-cli-telemetry. +

+

+ Configuration +

+

+ A command is run in the end of install process to initially populate your local package cache, to improve restore speed and enable offline access. This command will take up to a minute to complete and will only happen once. +

+
+ + \ No newline at end of file diff --git a/packaging/osx/clisdk/resources/pt-br.lproj/firstTimeWelcomeMessage.html b/packaging/osx/clisdk/resources/pt-br.lproj/firstTimeWelcomeMessage.html new file mode 100644 index 000000000..af9179267 --- /dev/null +++ b/packaging/osx/clisdk/resources/pt-br.lproj/firstTimeWelcomeMessage.html @@ -0,0 +1,29 @@ + + + + + Welcome to .NET Core! + + + +

+ Welcome to .NET Core! +

+

+ Learn more about .NET Core at https://aka.ms/dotnet-docs . Use dotnet --help to see available commands or go to https://aka.ms/dotnet-cli-docs. +

+

+ Telemetry +

+

+ The .NET Core tools collect usage data in order to improve your experience. The data is anonymous and does not include command-line arguments. The data is collected by Microsoft and shared with the community. You can opt out of telemetry by setting a DOTNET_CLI_TELEMETRY_OPTOUT environment variable to 1 using your favorite shell. You can read more about .NET Core tools telemetry at https://aka.ms/dotnet-cli-telemetry. +

+

+ Configuration +

+

+ A command is run in the end of install process to initially populate your local package cache, to improve restore speed and enable offline access. This command will take up to a minute to complete and will only happen once. +

+
+ + \ No newline at end of file diff --git a/packaging/osx/clisdk/resources/ru.lproj/firstTimeWelcomeMessage.html b/packaging/osx/clisdk/resources/ru.lproj/firstTimeWelcomeMessage.html new file mode 100644 index 000000000..af9179267 --- /dev/null +++ b/packaging/osx/clisdk/resources/ru.lproj/firstTimeWelcomeMessage.html @@ -0,0 +1,29 @@ + + + + + Welcome to .NET Core! + + + +

+ Welcome to .NET Core! +

+

+ Learn more about .NET Core at https://aka.ms/dotnet-docs . Use dotnet --help to see available commands or go to https://aka.ms/dotnet-cli-docs. +

+

+ Telemetry +

+

+ The .NET Core tools collect usage data in order to improve your experience. The data is anonymous and does not include command-line arguments. The data is collected by Microsoft and shared with the community. You can opt out of telemetry by setting a DOTNET_CLI_TELEMETRY_OPTOUT environment variable to 1 using your favorite shell. You can read more about .NET Core tools telemetry at https://aka.ms/dotnet-cli-telemetry. +

+

+ Configuration +

+

+ A command is run in the end of install process to initially populate your local package cache, to improve restore speed and enable offline access. This command will take up to a minute to complete and will only happen once. +

+
+ + \ No newline at end of file diff --git a/packaging/osx/clisdk/resources/tr.lproj/firstTimeWelcomeMessage.html b/packaging/osx/clisdk/resources/tr.lproj/firstTimeWelcomeMessage.html new file mode 100644 index 000000000..af9179267 --- /dev/null +++ b/packaging/osx/clisdk/resources/tr.lproj/firstTimeWelcomeMessage.html @@ -0,0 +1,29 @@ + + + + + Welcome to .NET Core! + + + +

+ Welcome to .NET Core! +

+

+ Learn more about .NET Core at https://aka.ms/dotnet-docs . Use dotnet --help to see available commands or go to https://aka.ms/dotnet-cli-docs. +

+

+ Telemetry +

+

+ The .NET Core tools collect usage data in order to improve your experience. The data is anonymous and does not include command-line arguments. The data is collected by Microsoft and shared with the community. You can opt out of telemetry by setting a DOTNET_CLI_TELEMETRY_OPTOUT environment variable to 1 using your favorite shell. You can read more about .NET Core tools telemetry at https://aka.ms/dotnet-cli-telemetry. +

+

+ Configuration +

+

+ A command is run in the end of install process to initially populate your local package cache, to improve restore speed and enable offline access. This command will take up to a minute to complete and will only happen once. +

+
+ + \ No newline at end of file diff --git a/packaging/osx/clisdk/resources/zh-hans.lproj/firstTimeWelcomeMessage.html b/packaging/osx/clisdk/resources/zh-hans.lproj/firstTimeWelcomeMessage.html new file mode 100644 index 000000000..af9179267 --- /dev/null +++ b/packaging/osx/clisdk/resources/zh-hans.lproj/firstTimeWelcomeMessage.html @@ -0,0 +1,29 @@ + + + + + Welcome to .NET Core! + + + +

+ Welcome to .NET Core! +

+

+ Learn more about .NET Core at https://aka.ms/dotnet-docs . Use dotnet --help to see available commands or go to https://aka.ms/dotnet-cli-docs. +

+

+ Telemetry +

+

+ The .NET Core tools collect usage data in order to improve your experience. The data is anonymous and does not include command-line arguments. The data is collected by Microsoft and shared with the community. You can opt out of telemetry by setting a DOTNET_CLI_TELEMETRY_OPTOUT environment variable to 1 using your favorite shell. You can read more about .NET Core tools telemetry at https://aka.ms/dotnet-cli-telemetry. +

+

+ Configuration +

+

+ A command is run in the end of install process to initially populate your local package cache, to improve restore speed and enable offline access. This command will take up to a minute to complete and will only happen once. +

+
+ + \ No newline at end of file diff --git a/packaging/osx/clisdk/resources/zh-hant.lproj/firstTimeWelcomeMessage.html b/packaging/osx/clisdk/resources/zh-hant.lproj/firstTimeWelcomeMessage.html new file mode 100644 index 000000000..af9179267 --- /dev/null +++ b/packaging/osx/clisdk/resources/zh-hant.lproj/firstTimeWelcomeMessage.html @@ -0,0 +1,29 @@ + + + + + Welcome to .NET Core! + + + +

+ Welcome to .NET Core! +

+

+ Learn more about .NET Core at https://aka.ms/dotnet-docs . Use dotnet --help to see available commands or go to https://aka.ms/dotnet-cli-docs. +

+

+ Telemetry +

+

+ The .NET Core tools collect usage data in order to improve your experience. The data is anonymous and does not include command-line arguments. The data is collected by Microsoft and shared with the community. You can opt out of telemetry by setting a DOTNET_CLI_TELEMETRY_OPTOUT environment variable to 1 using your favorite shell. You can read more about .NET Core tools telemetry at https://aka.ms/dotnet-cli-telemetry. +

+

+ Configuration +

+

+ A command is run in the end of install process to initially populate your local package cache, to improve restore speed and enable offline access. This command will take up to a minute to complete and will only happen once. +

+
+ + \ No newline at end of file diff --git a/packaging/osx/clisdk/scripts/postinstall b/packaging/osx/clisdk/scripts/postinstall index 690a9e989..54ea36c0d 100755 --- a/packaging/osx/clisdk/scripts/postinstall +++ b/packaging/osx/clisdk/scripts/postinstall @@ -11,4 +11,8 @@ INSTALL_DESTINATION=$2 # A temporary fix for the permissions issue(s) chmod -R 755 $INSTALL_DESTINATION +# Run 'dotnet new' as user to trigger the first time experience to initialize the cache +INSTALLER_USER=$(stat -f '%Su' $HOME) +su - $INSTALLER_USER -c "$INSTALL_DESTINATION/dotnet new > /dev/null 2>&1 || true" + exit 0 diff --git a/packaging/windows/clisdk/bundle.thm b/packaging/windows/clisdk/bundle.thm index ac5d67618..f7f30c2aa 100644 --- a/packaging/windows/clisdk/bundle.thm +++ b/packaging/windows/clisdk/bundle.thm @@ -1,6 +1,6 @@ - #(loc.Caption) + #(loc.Caption) Segoe UI Segoe UI Segoe UI @@ -52,6 +52,7 @@ #(loc.ProgressHeader) #(loc.ProgressLabel) #(loc.OverallProgressPackageText) + #(loc.FirstTimeWelcomeMessage) diff --git a/packaging/windows/clisdk/bundle.wxl b/packaging/windows/clisdk/bundle.wxl index 52c10481e..0140bab32 100644 --- a/packaging/windows/clisdk/bundle.wxl +++ b/packaging/windows/clisdk/bundle.wxl @@ -51,4 +51,11 @@ Ready? Set? Let's go!
&Do not close applications. A reboot will be required. &OK &Cancel + Welcome to .NET Core! +Learn more about .NET Core at https://aka.ms/dotnet-docs. Use dotnet --help to see available commands or go to https://aka.ms/dotnet-cli-docs. +Telemetry: +The .NET Core tools collect usage data in order to improve your experience. The data is anonymous and does not include command-line arguments. The data is collected by Microsoft and shared with the community. You can opt out of telemetry by setting a DOTNET_CLI_TELEMETRY_OPTOUT environment variable to 1 using your favorite shell. You can read more about .NET Core tools telemetry at https://aka.ms/dotnet-cli-telemetry. +Configuration: +A command is running in the end of install process to initially populate your local package cache, to improve restore speed and enable offline access. This command will take up to a minute to complete and will only happen once. + diff --git a/packaging/windows/clisdk/bundle.wxs b/packaging/windows/clisdk/bundle.wxs index e60a4bff6..9dbec29ce 100644 --- a/packaging/windows/clisdk/bundle.wxs +++ b/packaging/windows/clisdk/bundle.wxs @@ -38,6 +38,11 @@ + + + + + diff --git a/packaging/windows/clisdk/dotnet.wxs b/packaging/windows/clisdk/dotnet.wxs index 53dfbc94f..976bf5a55 100644 --- a/packaging/windows/clisdk/dotnet.wxs +++ b/packaging/windows/clisdk/dotnet.wxs @@ -1,45 +1,48 @@ - - - + + + - + - + - - - - - - - - - - - - + + + + + + + + + + + + + - + + + + + - + - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + + + diff --git a/packaging/windows/clisdk/generatebundle.ps1 b/packaging/windows/clisdk/generatebundle.ps1 index 2677fdd46..da5b4c83c 100644 --- a/packaging/windows/clisdk/generatebundle.ps1 +++ b/packaging/windows/clisdk/generatebundle.ps1 @@ -3,6 +3,7 @@ param( [Parameter(Mandatory=$true)][string]$CLISDKMSIFile, + [Parameter(Mandatory=$true)][string]$ASPNETRuntimeWixLibFile, [Parameter(Mandatory=$true)][string]$SharedFxMSIFile, [Parameter(Mandatory=$true)][string]$HostFxrMSIFile, [Parameter(Mandatory=$true)][string]$SharedHostMSIFile, @@ -69,6 +70,7 @@ function RunLightForBundle .\light.exe -nologo ` -cultures:en-us ` bundle.wixobj ` + $ASPNETRuntimeWixlibFile ` -ext WixBalExtension.dll ` -ext WixUtilExtension.dll ` -ext WixTagExtension.dll ` @@ -91,6 +93,11 @@ if(!(Test-Path $CLISDKMSIFile)) throw "$CLISDKMSIFile not found" } +if(!(Test-Path $ASPNETRuntimeWixLibFile)) +{ + throw "$ASPNETRuntimeWixLibFile not found" +} + Write-Host "Creating dotnet Bundle at $DotnetBundleOutput" if([string]::IsNullOrEmpty($WixRoot)) diff --git a/packaging/windows/clisdk/variables.wxi b/packaging/windows/clisdk/variables.wxi index 197031f6f..d76680561 100644 --- a/packaging/windows/clisdk/variables.wxi +++ b/packaging/windows/clisdk/variables.wxi @@ -17,9 +17,11 @@ + + diff --git a/run-build.ps1 b/run-build.ps1 index b408c5d29..867c3f20b 100644 --- a/run-build.ps1 +++ b/run-build.ps1 @@ -70,6 +70,9 @@ if (!(Test-Path $env:DOTNET_INSTALL_DIR_PJ)) # Disable first run since we want to control all package sources $env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 +# Don't resolve shared frameworks from user or global locations +$env:DOTNET_MULTILEVEL_LOOKUP=0 + # Enable vs test console logging $env:VSTEST_BUILD_TRACE=1 $env:VSTEST_TRACE_BUILD=1 @@ -85,9 +88,11 @@ if ($LastExitCode -ne 0) exit $LastExitCode } +# install the post-PJnistic stage0 +$dotnetInstallPath = Join-Path $toolsLocalPath "dotnet-install.ps1" -Write-Host "$dotnetInstallPath -Channel ""master"" -InstallDir $env:DOTNET_INSTALL_DIR_PJ -Architecture ""$Architecture"" -Version 1.0.0-preview2-1-003177" -Invoke-Expression "$dotnetInstallPath -Channel ""master"" -InstallDir $env:DOTNET_INSTALL_DIR_PJ -Architecture ""$Architecture"" -Version 1.0.0-preview2-1-003177" +Write-Host "$dotnetInstallPath -Channel ""master"" -Version ""2.0.0-preview1-005867"" -InstallDir $env:DOTNET_INSTALL_DIR -Architecture ""$Architecture""" +Invoke-Expression "$dotnetInstallPath -Channel ""master"" -Version ""2.0.0-preview1-005867"" -InstallDir $env:DOTNET_INSTALL_DIR -Architecture ""$Architecture""" if ($LastExitCode -ne 0) { Write-Output "The .NET CLI installation failed with exit code $LastExitCode" @@ -105,6 +110,6 @@ if ($NoBuild) else { dotnet msbuild build.proj /p:Architecture=$Architecture /p:GeneratePropsFile=true /t:WriteDynamicPropsToStaticPropsFiles - dotnet msbuild build.proj /m /v:diag /fl /flp:v=diag /p:Architecture=$Architecture $ExtraParameters + dotnet msbuild build.proj /m /v:normal /fl /flp:v=diag /p:Architecture=$Architecture $ExtraParameters if($LASTEXITCODE -ne 0) { throw "Failed to build" } } diff --git a/run-build.sh b/run-build.sh index d417b58d9..726e6d3bd 100755 --- a/run-build.sh +++ b/run-build.sh @@ -150,8 +150,12 @@ export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 export VSTEST_BUILD_TRACE=1 export VSTEST_TRACE_BUILD=1 + +# Don't resolve shared frameworks from user or global locations +DOTNET_MULTILEVEL_LOOKUP=0 + # Install a stage 0 -(set -x ; "$REPOROOT/scripts/obtain/dotnet-install.sh" --channel "master" --install-dir "$DOTNET_INSTALL_DIR" --architecture "$ARCHITECTURE" $LINUX_PORTABLE_INSTALL_ARGS) +(set -x ; "$REPOROOT/scripts/obtain/dotnet-install.sh" --channel "master" --version "2.0.0-preview1-005867" --install-dir "$DOTNET_INSTALL_DIR" --architecture "$ARCHITECTURE" $LINUX_PORTABLE_INSTALL_ARGS) EXIT_CODE=$? if [ $EXIT_CODE != 0 ]; then echo "run-build: Error: installing stage0 with exit code $EXIT_CODE." >&2 @@ -184,7 +188,7 @@ echo "${args[@]}" if [ $BUILD -eq 1 ]; then dotnet msbuild build.proj /p:Architecture=$ARCHITECTURE $CUSTOM_BUILD_ARGS /p:GeneratePropsFile=true /t:WriteDynamicPropsToStaticPropsFiles - dotnet msbuild build.proj /m /v:diag /fl /flp:v=diag /p:Architecture=$ARCHITECTURE $CUSTOM_BUILD_ARGS "${args[@]}" + dotnet msbuild build.proj /m /v:normal /fl /flp:v=diag /p:Architecture=$ARCHITECTURE $CUSTOM_BUILD_ARGS "${args[@]}" else echo "Not building due to --nobuild" echo "Command that would be run is: 'dotnet msbuild build.proj /m /p:Architecture=$ARCHITECTURE $CUSTOM_BUILD_ARGS ${args[@]}'" diff --git a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/DepsJsonBuilder.cs b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/DepsJsonBuilder.cs deleted file mode 100644 index c9a69f0c8..000000000 --- a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/DepsJsonBuilder.cs +++ /dev/null @@ -1,315 +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; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using Microsoft.Extensions.DependencyModel; -using NuGet.Frameworks; -using NuGet.Packaging; -using NuGet.Packaging.Core; -using NuGet.ProjectModel; - -namespace Microsoft.DotNet.Cli.Utils -{ - internal class DepsJsonBuilder - { - private readonly VersionFolderPathResolver _versionFolderPathResolver; - - public DepsJsonBuilder() - { - // This resolver is only used for building file names, so that base path is not required. - _versionFolderPathResolver = new VersionFolderPathResolver(rootPath: null); - } - - public DependencyContext Build( - SingleProjectInfo mainProjectInfo, - CompilationOptions compilationOptions, - LockFile lockFile, - NuGetFramework framework, - string runtime) - { - bool includeCompilationLibraries = compilationOptions != null; - - LockFileTarget lockFileTarget = lockFile.GetTarget(framework, runtime); - - IEnumerable runtimeExports = lockFileTarget.GetRuntimeLibraries(); - IEnumerable compilationExports = - includeCompilationLibraries ? - lockFileTarget.GetCompileLibraries() : - Enumerable.Empty(); - - var dependencyLookup = compilationExports - .Concat(runtimeExports) - .Distinct() - .Select(library => new Dependency(library.Name, library.Version.ToString())) - .ToDictionary(dependency => dependency.Name, StringComparer.OrdinalIgnoreCase); - - var libraryLookup = lockFile.Libraries.ToDictionary(l => l.Name, StringComparer.OrdinalIgnoreCase); - - var runtimeSignature = GenerateRuntimeSignature(runtimeExports); - - IEnumerable runtimeLibraries = - GetLibraries(runtimeExports, libraryLookup, dependencyLookup, runtime: true).Cast(); - - IEnumerable compilationLibraries; - if (includeCompilationLibraries) - { - CompilationLibrary projectCompilationLibrary = GetProjectCompilationLibrary( - mainProjectInfo, - lockFile, - lockFileTarget, - dependencyLookup); - compilationLibraries = new[] { projectCompilationLibrary } - .Concat( - GetLibraries(compilationExports, libraryLookup, dependencyLookup, runtime: false) - .Cast()); - } - else - { - compilationLibraries = Enumerable.Empty(); - } - - return new DependencyContext( - new TargetInfo(framework.DotNetFrameworkName, runtime, runtimeSignature, lockFileTarget.IsPortable()), - compilationOptions ?? CompilationOptions.Default, - compilationLibraries, - runtimeLibraries, - new RuntimeFallbacks[] { }); - } - - private static string GenerateRuntimeSignature(IEnumerable runtimeExports) - { - var sha1 = SHA1.Create(); - var builder = new StringBuilder(); - var packages = runtimeExports - .Where(libraryExport => libraryExport.Type == "package"); - var separator = "|"; - foreach (var libraryExport in packages) - { - builder.Append(libraryExport.Name); - builder.Append(separator); - builder.Append(libraryExport.Version.ToString()); - builder.Append(separator); - } - var hash = sha1.ComputeHash(Encoding.UTF8.GetBytes(builder.ToString())); - - builder.Clear(); - foreach (var hashByte in hash) - { - builder.AppendFormat("{0:x2}", hashByte); - } - return builder.ToString(); - } - - private List GetProjectDependencies( - LockFile lockFile, - LockFileTarget lockFileTarget, - Dictionary dependencyLookup) - { - - List dependencies = new List(); - - IEnumerable projectFileDependencies = lockFile - .ProjectFileDependencyGroups - .Where(dg => dg.FrameworkName == string.Empty || - dg.FrameworkName == lockFileTarget.TargetFramework.DotNetFrameworkName); - - foreach (string projectFileDependency in projectFileDependencies.SelectMany(dg => dg.Dependencies)) - { - int separatorIndex = projectFileDependency.IndexOf(' '); - string dependencyName = separatorIndex > 0 ? - projectFileDependency.Substring(0, separatorIndex) : - projectFileDependency; - - Dependency dependency; - if (dependencyLookup.TryGetValue(dependencyName, out dependency)) - { - dependencies.Add(dependency); - } - } - - return dependencies; - } - - private RuntimeLibrary GetProjectRuntimeLibrary( - SingleProjectInfo projectInfo, - LockFile lockFile, - LockFileTarget lockFileTarget, - Dictionary dependencyLookup) - { - - RuntimeAssetGroup[] runtimeAssemblyGroups = new[] { new RuntimeAssetGroup(string.Empty, projectInfo.GetOutputName()) }; - - List dependencies = GetProjectDependencies(lockFile, lockFileTarget, dependencyLookup); - - ResourceAssembly[] resourceAssemblies = projectInfo - .ResourceAssemblies - .Select(r => new ResourceAssembly(r.RelativePath, r.Culture)) - .ToArray(); - - return new RuntimeLibrary( - type: "project", - name: projectInfo.Name, - version: projectInfo.Version, - hash: string.Empty, - runtimeAssemblyGroups: runtimeAssemblyGroups, - nativeLibraryGroups: new RuntimeAssetGroup[] { }, - resourceAssemblies: resourceAssemblies, - dependencies: dependencies.ToArray(), - serviceable: false); - } - - private CompilationLibrary GetProjectCompilationLibrary( - SingleProjectInfo projectInfo, - LockFile lockFile, - LockFileTarget lockFileTarget, - Dictionary dependencyLookup) - { - List dependencies = GetProjectDependencies(lockFile, lockFileTarget, dependencyLookup); - - return new CompilationLibrary( - type: "project", - name: projectInfo.Name, - version: projectInfo.Version, - hash: string.Empty, - assemblies: new[] { projectInfo.GetOutputName() }, - dependencies: dependencies.ToArray(), - serviceable: false); - } - - private IEnumerable GetLibraries( - IEnumerable exports, - IDictionary libraryLookup, - IDictionary dependencyLookup, - bool runtime) - { - return exports.Select(export => GetLibrary(export, libraryLookup, dependencyLookup, runtime)); - } - - private Library GetLibrary( - LockFileTargetLibrary export, - IDictionary libraryLookup, - IDictionary dependencyLookup, - bool runtime) - { - var type = export.Type; - - // TEMPORARY: All packages are serviceable in RC2 - // See https://github.com/dotnet/cli/issues/2569 - var serviceable = export.Type == "package"; - var libraryDependencies = new HashSet(); - - foreach (PackageDependency libraryDependency in export.Dependencies) - { - Dependency dependency; - if (dependencyLookup.TryGetValue(libraryDependency.Id, out dependency)) - { - libraryDependencies.Add(dependency); - } - } - - string hash = string.Empty; - string path = null; - string hashPath = null; - LockFileLibrary library; - if (libraryLookup.TryGetValue(export.Name, out library)) - { - if (!string.IsNullOrEmpty(library.Sha512)) - { - hash = "sha512-" + library.Sha512; - hashPath = _versionFolderPathResolver.GetHashFileName(export.Name, export.Version); - } - - path = library.Path; - } - - if (runtime) - { - return new RuntimeLibrary( - type.ToLowerInvariant(), - export.Name, - export.Version.ToString(), - hash, - CreateRuntimeAssemblyGroups(export), - CreateNativeLibraryGroups(export), - export.ResourceAssemblies.FilterPlaceHolderFiles().Select(CreateResourceAssembly), - libraryDependencies, - serviceable, - path, - hashPath); - } - else - { - IEnumerable assemblies = export - .CompileTimeAssemblies - .FilterPlaceHolderFiles() - .Select(libraryAsset => libraryAsset.Path); - - return new CompilationLibrary( - type.ToString().ToLowerInvariant(), - export.Name, - export.Version.ToString(), - hash, - assemblies, - libraryDependencies, - serviceable, - path, - hashPath); - } - } - - private IReadOnlyList CreateRuntimeAssemblyGroups(LockFileTargetLibrary export) - { - List assemblyGroups = new List(); - - assemblyGroups.Add( - new RuntimeAssetGroup( - string.Empty, - export.RuntimeAssemblies.FilterPlaceHolderFiles().Select(a => a.Path))); - - foreach (var runtimeTargetsGroup in export.GetRuntimeTargetsGroups("runtime")) - { - assemblyGroups.Add( - new RuntimeAssetGroup( - runtimeTargetsGroup.Key, - runtimeTargetsGroup.Select(t => t.Path))); - } - - return assemblyGroups; - } - - private IReadOnlyList CreateNativeLibraryGroups(LockFileTargetLibrary export) - { - List nativeGroups = new List(); - - nativeGroups.Add( - new RuntimeAssetGroup( - string.Empty, - export.NativeLibraries.FilterPlaceHolderFiles().Select(a => a.Path))); - - foreach (var runtimeTargetsGroup in export.GetRuntimeTargetsGroups("native")) - { - nativeGroups.Add( - new RuntimeAssetGroup( - runtimeTargetsGroup.Key, - runtimeTargetsGroup.Select(t => t.Path))); - } - - return nativeGroups; - } - - private ResourceAssembly CreateResourceAssembly(LockFileItem resourceAssembly) - { - string locale; - if (!resourceAssembly.Properties.TryGetValue("locale", out locale)) - { - locale = null; - } - - return new ResourceAssembly(resourceAssembly.Path, locale); - } - } -} diff --git a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/IPackagedCommandSpecFactory.cs b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/IPackagedCommandSpecFactory.cs index 20f8a3302..5f409a09f 100644 --- a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/IPackagedCommandSpecFactory.cs +++ b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/IPackagedCommandSpecFactory.cs @@ -13,17 +13,7 @@ namespace Microsoft.DotNet.Cli.Utils string commandName, IEnumerable commandArguments, IEnumerable allowedExtensions, - string nugetPackagesRoot, - CommandResolutionStrategy commandResolutionStrategy, - string depsFilePath, - string runtimeConfigPath); - - CommandSpec CreateCommandSpecFromLibrary( - LockFileTargetLibrary toolLibrary, - string commandName, - IEnumerable commandArguments, - IEnumerable allowedExtensions, - IEnumerable packageFolders, + LockFile lockFile, CommandResolutionStrategy commandResolutionStrategy, string depsFilePath, string runtimeConfigPath); diff --git a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/IProject.cs b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/IProject.cs index 9a97bb1e5..534d77ebe 100644 --- a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/IProject.cs +++ b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/IProject.cs @@ -26,5 +26,7 @@ namespace Microsoft.DotNet.Cli.Utils NuGetFramework DotnetCliToolTargetFramework { get; } Dictionary EnvironmentVariables { get; } + + string ToolDepsJsonGeneratorProject { get; } } } diff --git a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/MSBuildProject.cs b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/MSBuildProject.cs index cb006e4a5..f5473c278 100644 --- a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/MSBuildProject.cs +++ b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/MSBuildProject.cs @@ -92,6 +92,19 @@ namespace Microsoft.DotNet.Cli.Utils } } + public string ToolDepsJsonGeneratorProject + { + get + { + var generatorProject = _project + .AllEvaluatedProperties + .FirstOrDefault(p => p.Name.Equals("ToolDepsJsonGeneratorProject")) + ?.EvaluatedValue; + + return generatorProject; + } + } + public MSBuildProject( string msBuildProjectPath, NuGetFramework framework, diff --git a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/PackagedCommandSpecFactory.cs b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/PackagedCommandSpecFactory.cs index e7bd1b33c..2ee8bcb6a 100644 --- a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/PackagedCommandSpecFactory.cs +++ b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/PackagedCommandSpecFactory.cs @@ -27,28 +27,7 @@ namespace Microsoft.DotNet.Cli.Utils string commandName, IEnumerable commandArguments, IEnumerable allowedExtensions, - string nugetPackagesRoot, - CommandResolutionStrategy commandResolutionStrategy, - string depsFilePath, - string runtimeConfigPath) - { - return CreateCommandSpecFromLibrary( - toolLibrary, - commandName, - commandArguments, - allowedExtensions, - new List { nugetPackagesRoot }, - commandResolutionStrategy, - depsFilePath, - runtimeConfigPath); - } - - public CommandSpec CreateCommandSpecFromLibrary( - LockFileTargetLibrary toolLibrary, - string commandName, - IEnumerable commandArguments, - IEnumerable allowedExtensions, - IEnumerable packageFolders, + LockFile lockFile, CommandResolutionStrategy commandResolutionStrategy, string depsFilePath, string runtimeConfigPath) @@ -72,7 +51,7 @@ namespace Microsoft.DotNet.Cli.Utils return null; } - var commandPath = GetCommandFilePath(packageFolders, toolLibrary, toolAssembly); + var commandPath = GetCommandFilePath(lockFile, toolLibrary, toolAssembly); if (!File.Exists(commandPath)) { @@ -89,21 +68,16 @@ namespace Microsoft.DotNet.Cli.Utils commandArguments, depsFilePath, commandResolutionStrategy, - packageFolders, + lockFile.GetNormalizedPackageFolders(), runtimeConfigPath); } private string GetCommandFilePath( - IEnumerable packageFolders, + LockFile lockFile, LockFileTargetLibrary toolLibrary, LockFileItem runtimeAssembly) { - var packageFoldersCount = packageFolders.Count(); - var userPackageFolder = packageFoldersCount == 1 ? string.Empty : packageFolders.First(); - var fallbackPackageFolders = packageFoldersCount > 1 ? packageFolders.Skip(1) : packageFolders; - - var packageDirectory = new FallbackPackagePathResolver(userPackageFolder, fallbackPackageFolders) - .GetPackageDirectory(toolLibrary.Name, toolLibrary.Version); + var packageDirectory = lockFile.GetPackageDirectory(toolLibrary); if (packageDirectory == null) { diff --git a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/PackagedCommandSpecFactoryWithCliRuntime.cs b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/PackagedCommandSpecFactoryWithCliRuntime.cs index a081bcd30..c22af40ba 100644 --- a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/PackagedCommandSpecFactoryWithCliRuntime.cs +++ b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/PackagedCommandSpecFactoryWithCliRuntime.cs @@ -21,11 +21,51 @@ namespace Microsoft.DotNet.Cli.Utils { if(PrefersCliRuntime(commandPath)) { - arguments.Add("--fx-version"); - arguments.Add(new Muxer().SharedFxVersion); + var runtimeConfigFile = Path.ChangeExtension(commandPath, FileNameSuffixes.RuntimeConfigJson); + + if (!File.Exists(runtimeConfigFile)) + { + throw new GracefulException(string.Format(LocalizableStrings.CouldNotFindToolRuntimeConfigFile, + nameof(PackagedCommandSpecFactory), + Path.GetFileName(commandPath))); + } + + var runtimeConfig = new RuntimeConfig(runtimeConfigFile); + + var muxer = new Muxer(); + + Version currentFrameworkSimpleVersion = GetVersionWithoutPrerelease(muxer.SharedFxVersion); + Version toolFrameworkSimpleVersion = GetVersionWithoutPrerelease(runtimeConfig.Framework.Version); + + if (currentFrameworkSimpleVersion.Major != toolFrameworkSimpleVersion.Major) + { + Reporter.Verbose.WriteLine( + string.Format( + LocalizableStrings.IgnoringPreferCLIRuntimeFile, + nameof(PackagedCommandSpecFactory), + runtimeConfig.Framework.Version, + muxer.SharedFxVersion)); + } + else + { + arguments.Add("--fx-version"); + arguments.Add(muxer.SharedFxVersion); + } } } + private static Version GetVersionWithoutPrerelease(string version) + { + int dashOrPlusIndex = version.IndexOfAny(new char[] { '-', '+' }); + + if (dashOrPlusIndex >= 0) + { + version = version.Substring(0, dashOrPlusIndex); + } + + return new Version(version); + } + private static bool PrefersCliRuntime(string commandPath) { var libTFMPackageDirectory = Path.GetDirectoryName(commandPath); @@ -35,7 +75,7 @@ namespace Microsoft.DotNet.Cli.Utils Reporter.Verbose.WriteLine( string.Format( LocalizableStrings.LookingForPreferCliRuntimeFile, - "packagedcommandspecfactory", + nameof(PackagedCommandSpecFactory), preferCliRuntimePath)); return File.Exists(preferCliRuntimePath); diff --git a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/ProjectDependenciesCommandResolver.cs b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/ProjectDependenciesCommandResolver.cs index 9c1e97e5b..557ca3b25 100644 --- a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/ProjectDependenciesCommandResolver.cs +++ b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/ProjectDependenciesCommandResolver.cs @@ -120,15 +120,13 @@ namespace Microsoft.DotNet.Cli.Utils var lockFile = project.GetLockFile(); var toolLibrary = GetToolLibraryForContext(lockFile, commandName, framework); - var normalizedNugetPackagesRoot = - PathUtility.EnsureNoTrailingDirectorySeparator(lockFile.PackageFolders.First().Path); var commandSpec = _packagedCommandSpecFactory.CreateCommandSpecFromLibrary( toolLibrary, commandName, commandArguments, allowedExtensions, - normalizedNugetPackagesRoot, + lockFile, s_commandResolutionStrategy, depsFilePath, runtimeConfigPath); diff --git a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/ProjectToolsCommandResolver.cs b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/ProjectToolsCommandResolver.cs index 85f82bcd2..a75472142 100644 --- a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/ProjectToolsCommandResolver.cs +++ b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/ProjectToolsCommandResolver.cs @@ -134,12 +134,35 @@ namespace Microsoft.DotNet.Cli.Utils ProjectToolsCommandResolverName, string.Join(Environment.NewLine, possiblePackageRoots.Select((p) => $"- {p}")))); - var toolPackageFramework = project.DotnetCliToolTargetFramework; + List toolFrameworksToCheck = new List(); + toolFrameworksToCheck.Add(project.DotnetCliToolTargetFramework); - var toolLockFile = GetToolLockFile( - toolLibraryRange, - toolPackageFramework, - possiblePackageRoots); + // NuGet restore in Visual Studio may restore for netcoreapp1.0. So if that happens, fall back to + // looking for a netcoreapp1.0 or netcoreapp1.1 tool restore. + if (project.DotnetCliToolTargetFramework.Framework == FrameworkConstants.FrameworkIdentifiers.NetCoreApp && + project.DotnetCliToolTargetFramework.Version >= new Version(2, 0, 0)) + { + toolFrameworksToCheck.Add(NuGetFramework.Parse("netcoreapp1.1")); + toolFrameworksToCheck.Add(NuGetFramework.Parse("netcoreapp1.0")); + } + + + LockFile toolLockFile = null; + NuGetFramework toolTargetFramework = null; ; + + foreach (var toolFramework in toolFrameworksToCheck) + { + toolLockFile = GetToolLockFile( + toolLibraryRange, + toolFramework, + possiblePackageRoots); + + if (toolLockFile != null) + { + toolTargetFramework = toolFramework; + break; + } + } if (toolLockFile == null) { @@ -152,7 +175,7 @@ namespace Microsoft.DotNet.Cli.Utils toolLockFile.Path)); var toolLibrary = toolLockFile.Targets - .FirstOrDefault(t => toolPackageFramework == t.TargetFramework) + .FirstOrDefault(t => toolTargetFramework == t.TargetFramework) ?.Libraries.FirstOrDefault( l => StringComparer.OrdinalIgnoreCase.Equals(l.Name, toolLibraryRange.Name)); if (toolLibrary == null) @@ -168,12 +191,10 @@ namespace Microsoft.DotNet.Cli.Utils var depsFilePath = GetToolDepsFilePath( toolLibraryRange, - toolPackageFramework, + toolTargetFramework, toolLockFile, - depsFileRoot); - - var packageFolders = toolLockFile.PackageFolders.Select(p => - PathUtility.EnsureNoTrailingDirectorySeparator(p.Path)); + depsFileRoot, + project.ToolDepsJsonGeneratorProject); Reporter.Verbose.WriteLine(string.Format( LocalizableStrings.AttemptingToCreateCommandSpec, @@ -184,7 +205,7 @@ namespace Microsoft.DotNet.Cli.Utils commandName, args, _allowedCommandExtensions, - packageFolders, + toolLockFile, s_commandResolutionStrategy, depsFilePath, null); @@ -281,7 +302,8 @@ namespace Microsoft.DotNet.Cli.Utils SingleProjectInfo toolLibrary, NuGetFramework framework, LockFile toolLockFile, - string depsPathRoot) + string depsPathRoot, + string toolDepsJsonGeneratorProject) { var depsJsonPath = Path.Combine( depsPathRoot, @@ -292,7 +314,7 @@ namespace Microsoft.DotNet.Cli.Utils ProjectToolsCommandResolverName, depsJsonPath)); - EnsureToolJsonDepsFileExists(toolLockFile, framework, depsJsonPath, toolLibrary); + EnsureToolJsonDepsFileExists(toolLockFile, framework, depsJsonPath, toolLibrary, toolDepsJsonGeneratorProject); return depsJsonPath; } @@ -301,11 +323,12 @@ namespace Microsoft.DotNet.Cli.Utils LockFile toolLockFile, NuGetFramework framework, string depsPath, - SingleProjectInfo toolLibrary) + SingleProjectInfo toolLibrary, + string toolDepsJsonGeneratorProject) { if (!File.Exists(depsPath)) { - GenerateDepsJsonFile(toolLockFile, framework, depsPath, toolLibrary); + GenerateDepsJsonFile(toolLockFile, framework, depsPath, toolLibrary, toolDepsJsonGeneratorProject); } } @@ -313,21 +336,80 @@ namespace Microsoft.DotNet.Cli.Utils LockFile toolLockFile, NuGetFramework framework, string depsPath, - SingleProjectInfo toolLibrary) + SingleProjectInfo toolLibrary, + string toolDepsJsonGeneratorProject) { + if (string.IsNullOrEmpty(toolDepsJsonGeneratorProject) || + !File.Exists(toolDepsJsonGeneratorProject)) + { + throw new GracefulException(LocalizableStrings.DepsJsonGeneratorProjectNotSet); + } + Reporter.Verbose.WriteLine(string.Format( LocalizableStrings.GeneratingDepsJson, depsPath)); - var dependencyContext = new DepsJsonBuilder() - .Build(toolLibrary, null, toolLockFile, framework, null); - var tempDepsFile = Path.GetTempFileName(); - using (var fileStream = File.Open(tempDepsFile, FileMode.Open, FileAccess.Write)) - { - var dependencyContextWriter = new DependencyContextWriter(); - dependencyContextWriter.Write(dependencyContext, fileStream); + var args = new List(); + + args.Add(toolDepsJsonGeneratorProject); + args.Add($"/p:ProjectAssetsFile=\"{toolLockFile.Path}\""); + args.Add($"/p:ToolName={toolLibrary.Name}"); + args.Add($"/p:ProjectDepsFilePath={tempDepsFile}"); + + var toolTargetFramework = toolLockFile.Targets.First().TargetFramework.GetShortFolderName(); + args.Add($"/p:TargetFramework={toolTargetFramework}"); + + + // Look for the .props file in the Microsoft.NETCore.App package, until NuGet + // generates .props and .targets files for tool restores (https://github.com/NuGet/Home/issues/5037) + var platformLibrary = toolLockFile.Targets + .FirstOrDefault(t => framework == t.TargetFramework) + ?.GetPlatformLibrary(); + + if (platformLibrary != null) + { + string buildRelativePath = platformLibrary.Build.FirstOrDefault()?.Path; + + var platformLibraryPath = toolLockFile.GetPackageDirectory(platformLibrary); + + if (platformLibraryPath != null && buildRelativePath != null) + { + // Get rid of "_._" filename + buildRelativePath = Path.GetDirectoryName(buildRelativePath); + + string platformLibraryBuildFolderPath = Path.Combine(platformLibraryPath, buildRelativePath); + var platformLibraryPropsFile = Directory.GetFiles(platformLibraryBuildFolderPath, "*.props").FirstOrDefault(); + + if (platformLibraryPropsFile != null) + { + args.Add($"/p:AdditionalImport={platformLibraryPropsFile}"); + } + } + } + + // Delete temporary file created by Path.GetTempFileName(), otherwise the GenerateBuildDependencyFile target + // will think the deps file is up-to-date and skip executing + File.Delete(tempDepsFile); + + var msBuildExePath = _environment.GetEnvironmentVariable(Constants.MSBUILD_EXE_PATH); + + msBuildExePath = string.IsNullOrEmpty(msBuildExePath) ? + Path.Combine(AppContext.BaseDirectory, "MSBuild.dll") : + msBuildExePath; + + var result = new MSBuildForwardingAppWithoutLogging(args, msBuildExePath) + .GetProcessStartInfo() + .ExecuteAndCaptureOutput(out string stdOut, out string stdErr); + + if (result != 0) + { + Reporter.Verbose.WriteLine(string.Format( + LocalizableStrings.UnableToGenerateDepsJson, + stdOut + Environment.NewLine + stdErr)); + + throw new GracefulException(string.Format(LocalizableStrings.UnableToGenerateDepsJson, toolDepsJsonGeneratorProject)); } try diff --git a/src/Microsoft.DotNet.Cli.Utils/Extensions/LockFileExtensions.cs b/src/Microsoft.DotNet.Cli.Utils/Extensions/LockFileExtensions.cs new file mode 100644 index 000000000..a54a502a9 --- /dev/null +++ b/src/Microsoft.DotNet.Cli.Utils/Extensions/LockFileExtensions.cs @@ -0,0 +1,36 @@ +// 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 Microsoft.DotNet.Tools.Common; +using NuGet.Packaging; +using NuGet.ProjectModel; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Microsoft.DotNet.Cli.Utils +{ + static class LockFileExtensions + { + public static string GetPackageDirectory(this LockFile lockFile, LockFileTargetLibrary library) + { + var packageFolders = lockFile.GetNormalizedPackageFolders(); + + var packageFoldersCount = packageFolders.Count(); + var userPackageFolder = packageFoldersCount == 1 ? string.Empty : packageFolders.First(); + var fallbackPackageFolders = packageFoldersCount > 1 ? packageFolders.Skip(1) : packageFolders; + + var packageDirectory = new FallbackPackagePathResolver(userPackageFolder, fallbackPackageFolders) + .GetPackageDirectory(library.Name, library.Version); + + return packageDirectory; + } + + public static IEnumerable GetNormalizedPackageFolders(this LockFile lockFile) + { + return lockFile.PackageFolders.Select(p => + PathUtility.EnsureNoTrailingDirectorySeparator(p.Path)); + } + } +} diff --git a/src/Microsoft.DotNet.Cli.Utils/ForwardingAppImplementation.cs b/src/Microsoft.DotNet.Cli.Utils/ForwardingAppImplementation.cs new file mode 100644 index 000000000..72e65aa3c --- /dev/null +++ b/src/Microsoft.DotNet.Cli.Utils/ForwardingAppImplementation.cs @@ -0,0 +1,108 @@ +// 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.Collections.Generic; +using System.Diagnostics; +using Microsoft.DotNet.Cli.Utils; + +namespace Microsoft.DotNet.Cli.Utils +{ + /// + /// A class which encapsulates logic needed to forward arguments from the current process to another process + /// invoked with the dotnet.exe host. + /// + internal class ForwardingAppImplementation + { + private const string HostExe = "dotnet"; + + private readonly string _forwardApplicationPath; + private readonly IEnumerable _argsToForward; + private readonly string _depsFile; + private readonly string _runtimeConfig; + private readonly string _additionalProbingPath; + private Dictionary _environmentVariables; + + private readonly string[] _allArgs; + + public ForwardingAppImplementation( + string forwardApplicationPath, + IEnumerable argsToForward, + string depsFile = null, + string runtimeConfig = null, + string additionalProbingPath = null, + Dictionary environmentVariables = null) + { + _forwardApplicationPath = forwardApplicationPath; + _argsToForward = argsToForward; + _depsFile = depsFile; + _runtimeConfig = runtimeConfig; + _additionalProbingPath = additionalProbingPath; + _environmentVariables = environmentVariables; + + var allArgs = new List(); + allArgs.Add("exec"); + + if (_depsFile != null) + { + allArgs.Add("--depsfile"); + allArgs.Add(_depsFile); + } + + if (_runtimeConfig != null) + { + allArgs.Add("--runtimeconfig"); + allArgs.Add(_runtimeConfig); + } + + if (_additionalProbingPath != null) + { + allArgs.Add("--additionalprobingpath"); + allArgs.Add(_additionalProbingPath); + } + + allArgs.Add(_forwardApplicationPath); + allArgs.AddRange(_argsToForward); + + _allArgs = allArgs.ToArray(); + } + + public int Execute() + { + return GetProcessStartInfo().Execute(); + } + + public ProcessStartInfo GetProcessStartInfo() + { + var processInfo = new ProcessStartInfo + { + FileName = GetHostExeName(), + Arguments = ArgumentEscaper.EscapeAndConcatenateArgArrayForProcessStart(_allArgs), + UseShellExecute = false + }; + + if (_environmentVariables != null) + { + foreach (var entry in _environmentVariables) + { + processInfo.Environment[entry.Key] = entry.Value; + } + } + + return processInfo; + } + + public ForwardingAppImplementation WithEnvironmentVariable(string name, string value) + { + _environmentVariables = _environmentVariables ?? new Dictionary(); + + _environmentVariables.Add(name, value); + + return this; + } + + private string GetHostExeName() + { + return $"{HostExe}{FileNameSuffixes.CurrentPlatform.Exe}"; + } + } +} diff --git a/src/Microsoft.DotNet.Cli.Utils/LocalizableStrings.cs b/src/Microsoft.DotNet.Cli.Utils/LocalizableStrings.cs index 8a3e20014..3b2f17829 100644 --- a/src/Microsoft.DotNet.Cli.Utils/LocalizableStrings.cs +++ b/src/Microsoft.DotNet.Cli.Utils/LocalizableStrings.cs @@ -19,6 +19,10 @@ namespace Microsoft.DotNet.Cli.Utils public const string LookingForPreferCliRuntimeFile = "{0}: Looking for prefercliruntime file at `{1}`"; + public const string IgnoringPreferCLIRuntimeFile = "{0}: Ignoring prefercliruntime file as the tool target framework ({1}) has a different major version than the current CLI runtime ({2})"; + + public const string CouldNotFindToolRuntimeConfigFile = "{0}: Could not find runtimeconfig.json file for tool {1}"; + public const string AttemptingToResolve = "{0}: attempting to resolve {1}"; public const string DidNotFindAMatchingProject = "{0}: Did not find a matching project {1}."; @@ -61,6 +65,8 @@ namespace Microsoft.DotNet.Cli.Utils public const string UnableToGenerateDepsJson = "unable to generate deps.json, it may have been already generated: {0}"; + public const string DepsJsonGeneratorProjectNotSet = "Unable to find deps.json generator project."; + public const string UnableToDeleteTemporaryDepsJson = "unable to delete temporary deps.json file: {0}"; public const string VersionForPackageCouldNotBeResolved = "Version for package `{0}` could not be resolved."; diff --git a/src/Microsoft.DotNet.Cli.Utils/MSBuildForwardingAppWithoutLogging.cs b/src/Microsoft.DotNet.Cli.Utils/MSBuildForwardingAppWithoutLogging.cs new file mode 100644 index 000000000..351ce43af --- /dev/null +++ b/src/Microsoft.DotNet.Cli.Utils/MSBuildForwardingAppWithoutLogging.cs @@ -0,0 +1,87 @@ +// 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; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; + +namespace Microsoft.DotNet.Cli.Utils +{ + internal class MSBuildForwardingAppWithoutLogging + { + private const string MSBuildExeName = "MSBuild.dll"; + + private const string SdksDirectoryName = "Sdks"; + + private readonly ForwardingAppImplementation _forwardingApp; + + private readonly Dictionary _msbuildRequiredEnvironmentVariables = + new Dictionary + { + { "MSBuildExtensionsPath", AppContext.BaseDirectory }, + { "CscToolExe", GetRunCscPath() }, + { "MSBuildSDKsPath", GetMSBuildSDKsPath() } + }; + + private readonly IEnumerable _msbuildRequiredParameters = + new List { "/m", "/v:m" }; + + public MSBuildForwardingAppWithoutLogging(IEnumerable argsToForward, string msbuildPath = null) + { + _forwardingApp = new ForwardingAppImplementation( + msbuildPath ?? GetMSBuildExePath(), + _msbuildRequiredParameters.Concat(argsToForward.Select(Escape)), + environmentVariables: _msbuildRequiredEnvironmentVariables); + } + + public virtual ProcessStartInfo GetProcessStartInfo() + { + return _forwardingApp + .GetProcessStartInfo(); + } + + public int Execute() + { + return GetProcessStartInfo().Execute(); + } + + private static string Escape(string arg) => + // this is a workaround for https://github.com/Microsoft/msbuild/issues/1622 + (arg.StartsWith("/p:RestoreSources=", StringComparison.OrdinalIgnoreCase)) ? + arg.Replace(";", "%3B") + .Replace("://", ":%2F%2F") : + arg; + + private static string GetMSBuildExePath() + { + return Path.Combine( + AppContext.BaseDirectory, + MSBuildExeName); + } + + private static string GetMSBuildSDKsPath() + { + var envMSBuildSDKsPath = Environment.GetEnvironmentVariable("MSBuildSDKsPath"); + + if (envMSBuildSDKsPath != null) + { + return envMSBuildSDKsPath; + } + + return Path.Combine( + AppContext.BaseDirectory, + SdksDirectoryName); + } + + private static string GetRunCscPath() + { + var scriptExtension = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".cmd" : ".sh"; + return Path.Combine(AppContext.BaseDirectory, "Roslyn", $"RunCsc{scriptExtension}"); + } + } +} + diff --git a/src/Microsoft.DotNet.Cli.Utils/Microsoft.DotNet.Cli.Utils.csproj b/src/Microsoft.DotNet.Cli.Utils/Microsoft.DotNet.Cli.Utils.csproj index 5d14b7b57..bc95703fb 100644 --- a/src/Microsoft.DotNet.Cli.Utils/Microsoft.DotNet.Cli.Utils.csproj +++ b/src/Microsoft.DotNet.Cli.Utils/Microsoft.DotNet.Cli.Utils.csproj @@ -20,7 +20,8 @@ -
+ +
@@ -31,4 +32,4 @@ - \ No newline at end of file + diff --git a/src/Microsoft.DotNet.Cli.Utils/ProcessStartInfoExtensions.cs b/src/Microsoft.DotNet.Cli.Utils/ProcessStartInfoExtensions.cs new file mode 100644 index 000000000..0d11313b9 --- /dev/null +++ b/src/Microsoft.DotNet.Cli.Utils/ProcessStartInfoExtensions.cs @@ -0,0 +1,60 @@ +// 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; +using System.Diagnostics; + +namespace Microsoft.DotNet.Cli.Utils +{ + internal static class ProcessStartInfoExtensions + { + public static int Execute(this ProcessStartInfo startInfo) + { + if (startInfo == null) + { + throw new ArgumentNullException(nameof(startInfo)); + } + + var process = new Process + { + StartInfo = startInfo + }; + + process.Start(); + process.WaitForExit(); + + return process.ExitCode; + } + + public static int ExecuteAndCaptureOutput(this ProcessStartInfo startInfo, out string stdOut, out string stdErr) + { + var outStream = new StreamForwarder().Capture(); + var errStream = new StreamForwarder().Capture(); + + startInfo.RedirectStandardOutput = true; + startInfo.RedirectStandardError = true; + + var process = new Process + { + StartInfo = startInfo + }; + + process.EnableRaisingEvents = true; + + process.Start(); + + var taskOut = outStream.BeginRead(process.StandardOutput); + var taskErr = errStream.BeginRead(process.StandardError); + + process.WaitForExit(); + + taskOut.Wait(); + taskErr.Wait(); + + stdOut = outStream.CapturedOutput; + stdErr = errStream.CapturedOutput; + + return process.ExitCode; + } + } +} diff --git a/src/Microsoft.DotNet.Configurer/NuGetConfig.cs b/src/Microsoft.DotNet.Configurer/NuGetConfig.cs index fb7b9292c..ec5ffc4dd 100644 --- a/src/Microsoft.DotNet.Configurer/NuGetConfig.cs +++ b/src/Microsoft.DotNet.Configurer/NuGetConfig.cs @@ -9,7 +9,7 @@ namespace Microsoft.DotNet.Configurer { public class NuGetConfig : INuGetConfig { - public const string FallbackPackageFolders = "fallbackPackageFolders"; + public const string FallbackPackageFolders = "packageSources"; private ISettings _settings; diff --git a/src/Microsoft.DotNet.MSBuildSdkResolver/Interop.Common.cs b/src/Microsoft.DotNet.MSBuildSdkResolver/Interop.Common.cs new file mode 100644 index 000000000..580d1220b --- /dev/null +++ b/src/Microsoft.DotNet.MSBuildSdkResolver/Interop.Common.cs @@ -0,0 +1,36 @@ +// 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; +using System.Diagnostics; +using System.Text; + +namespace Microsoft.DotNet.MSBuildSdkResolver +{ + internal static partial class Interop + { + internal static string hostfxr_resolve_sdk(string exe_dir, string working_dir) + { + var buffer = new StringBuilder(capacity: 64); + + for (;;) + { + int size = hostfxr_resolve_sdk(exe_dir, working_dir, buffer, buffer.Capacity); + if (size <= 0) + { + Debug.Assert(size == 0); + return null; + } + + if (size <= buffer.Capacity) + { + break; + } + + buffer.Capacity = size; + } + + return buffer.ToString(); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.DotNet.MSBuildSdkResolver/Interop.NETFramework.cs b/src/Microsoft.DotNet.MSBuildSdkResolver/Interop.NETFramework.cs new file mode 100644 index 000000000..d1d567e8b --- /dev/null +++ b/src/Microsoft.DotNet.MSBuildSdkResolver/Interop.NETFramework.cs @@ -0,0 +1,45 @@ +// 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. + +#if NET46 + +using System; +using System.IO; +using System.Runtime.InteropServices; +using System.Text; + +namespace Microsoft.DotNet.MSBuildSdkResolver +{ + internal static partial class Interop + { + static Interop() + { + PreloadLibrary("hostfxr.dll"); + } + + // MSBuild SDK resolvers are required to be AnyCPU, but we have a native dependency and .NETFramework does not + // have a built-in facility for dynamically loading user native dlls for the appropriate platform. We therefore + // preload the version with the correct architecture (from a corresponding sub-folder relative to us) on static + // construction so that subsequent P/Invokes can find it. + private static void PreloadLibrary(string dllFileName) + { + string basePath = Path.GetDirectoryName(typeof(Interop).Assembly.Location); + string architecture = IntPtr.Size == 8 ? "x64" : "x86"; + string dllPath = Path.Combine(basePath, architecture, dllFileName); + + // return value is intentially ignored as we let the subsequent P/Invokes fail naturally. + LoadLibraryExW(dllPath, IntPtr.Zero, LOAD_WITH_ALTERED_SEARCH_PATH); + } + + // lpFileName passed to LoadLibraryEx must be a full path. + private const int LOAD_WITH_ALTERED_SEARCH_PATH = 0x8; + + [DllImport("kernel32", CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] + private static extern IntPtr LoadLibraryExW(string lpFileName, IntPtr hFile, int dwFlags); + + [DllImport("hostfxr", CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] + private static extern int hostfxr_resolve_sdk(string exe_dir, string working_dir, [Out] StringBuilder buffer, int buffer_size); + } +} + +#endif // NET46 \ No newline at end of file diff --git a/src/Microsoft.DotNet.MSBuildSdkResolver/Interop.NETStandard.cs b/src/Microsoft.DotNet.MSBuildSdkResolver/Interop.NETStandard.cs new file mode 100644 index 000000000..bff6fd84b --- /dev/null +++ b/src/Microsoft.DotNet.MSBuildSdkResolver/Interop.NETStandard.cs @@ -0,0 +1,37 @@ +// 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. + +// NOTE: Currently, only the NET46 build ships (with Visual Studio/desktop msbuild), +// but the netstandard1.3 adaptation here acts a proof-of-concept for cross-platform +// portability of the underlying hostfxr API and gives us build and test coverage +// on non-Windows machines. +#if NETSTANDARD1_3 + +using System.Runtime.InteropServices; +using System.Text; + +namespace Microsoft.DotNet.MSBuildSdkResolver +{ + internal static partial class Interop + { + internal static readonly bool s_runningOnWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); + + private static int hostfxr_resolve_sdk(string exe_dir, string working_dir, [Out] StringBuilder buffer, int buffer_size) + { + // hostfxr string encoding is platform -specific so dispatch to the + // appropriately annotated P/Invoke for the current platform. + return s_runningOnWindows + ? windows_hostfxr_resolve_sdk(exe_dir, working_dir, buffer, buffer_size) + : unix_hostfxr_resolve_sdk(exe_dir, working_dir, buffer, buffer_size); + } + + [DllImport("hostfxr", EntryPoint = nameof(hostfxr_resolve_sdk), CharSet = CharSet.Unicode, ExactSpelling=true, CallingConvention = CallingConvention.Cdecl)] + private static extern int windows_hostfxr_resolve_sdk(string exe_dir, string working_dir, [Out] StringBuilder buffer, int buffer_size); + + // CharSet.Ansi is UTF8 on Unix + [DllImport("hostfxr", EntryPoint = nameof(hostfxr_resolve_sdk), CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] + private static extern int unix_hostfxr_resolve_sdk(string exe_dir, string working_dir, [Out] StringBuilder buffer, int buffer_size); + } +} + +#endif // NETSTANDARD1_3 \ No newline at end of file diff --git a/src/Microsoft.DotNet.MSBuildSdkResolver/MSBuildSdkResolver.cs b/src/Microsoft.DotNet.MSBuildSdkResolver/MSBuildSdkResolver.cs new file mode 100644 index 000000000..6048d3d59 --- /dev/null +++ b/src/Microsoft.DotNet.MSBuildSdkResolver/MSBuildSdkResolver.cs @@ -0,0 +1,126 @@ +// 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 Microsoft.Build.Framework; +using System; +using System.Collections.Generic; +using System.IO; + +namespace Microsoft.DotNet.MSBuildSdkResolver +{ + public sealed class DotNetMSBuildSdkResolver : SdkResolver + { + public override string Name => "Microsoft.DotNet.MSBuildSdkResolver"; + + // Default resolver has priority 10000 and we want to go before it and leave room on either side of us. + public override int Priority => 5000; + + public override SdkResult Resolve(SdkReference sdkReference, SdkResolverContext context, SdkResultFactory factory) + { + // These are overrides that are used to force the resolved SDK tasks and targets to come from a given + // base directory and report a given version to msbuild (which may be null if unknown. One key use case + // for this is to test SDK tasks and targets without deploying them inside the .NET Core SDK. + string msbuildSdksDir = Environment.GetEnvironmentVariable("DOTNET_MSBUILD_SDK_RESOLVER_SDKS_DIR"); + string netcoreSdkVersion = Environment.GetEnvironmentVariable("DOTNET_MSBUILD_SDK_RESOLVER_SDKS_VER"); + + if (msbuildSdksDir == null) + { + string netcoreSdkDir = ResolveNetcoreSdkDirectory(context); + if (netcoreSdkDir == null) + { + return factory.IndicateFailure( + new[] + { + "Unable to locate the .NET Core SDK. Check that it is installed and that the version" + + " specified in global.json (if any) matches the installed version." + }); + } + + msbuildSdksDir = Path.Combine(netcoreSdkDir, "Sdks"); + netcoreSdkVersion = new DirectoryInfo(netcoreSdkDir).Name;; + } + + string msbuildSdkDir = Path.Combine(msbuildSdksDir, sdkReference.Name, "Sdk"); + if (!Directory.Exists(msbuildSdkDir)) + { + return factory.IndicateFailure( + new[] + { + $"{msbuildSdkDir} not found. Check that a recent enough .NET Core SDK is installed" + + " and/or increase the version specified in global.json. " + }); + } + + return factory.IndicateSuccess(msbuildSdkDir, netcoreSdkVersion); + } + + private string ResolveNetcoreSdkDirectory(SdkResolverContext context) + { + foreach (string exeDir in GetDotnetExeDirectoryCandidates()) + { + string workingDir = context.SolutionFilePath ?? context.ProjectFilePath; + string netcoreSdkDir = Interop.hostfxr_resolve_sdk(exeDir, workingDir); + + if (netcoreSdkDir != null) + { + return netcoreSdkDir; + } + } + + return null; + } + + // Search for [ProgramFiles]\dotnet in this order. + private static readonly string[] s_programFiles = new[] + { + // "c:\Program Files" on x64 machine regardless process architecture. + // Undefined on x86 machines. + "ProgramW6432", + + // "c:\Program Files (x86)" on x64 machine regardless of process architecture + // Undefined on x86 machines. + "ProgramFiles(x86)", + + // "c:\Program Files" or "C:\Program Files (x86)" on x64 machine depending on process architecture. + // "c:\Program Files" on x86 machines (therefore not redundant with the two locations above in that case). + // + // NOTE: hostfxr will search this on its own if multilevel lookup is not disable, but we do it explicitly + // to prevent an environment with disabled multilevel lookup from crippling desktop msbuild and VS. + "ProgramFiles", + }; + + private List GetDotnetExeDirectoryCandidates() + { + string environmentOverride = Environment.GetEnvironmentVariable("DOTNET_MSBUILD_SDK_RESOLVER_CLI_DIR"); + if (environmentOverride != null) + { + return new List(capacity: 1) { environmentOverride }; + } + + // Initial capacity is 2 because while there are 3 candidates, we expect at most 2 unique ones (x64 + x86) + // Also, N=3 here means that we needn't be concerned with the O(N^2) complexity of the foreach + contains. + var candidates = new List(capacity: 2); + foreach (string variable in s_programFiles) + { + string directory = Environment.GetEnvironmentVariable(variable); + if (directory == null) + { + continue; + } + + directory = Path.Combine(directory, "dotnet"); + if (!candidates.Contains(directory)) + { + candidates.Add(directory); + } + } + + if (candidates.Count == 0) + { + candidates.Add(null); + } + + return candidates; + } + } +} diff --git a/src/Microsoft.DotNet.MSBuildSdkResolver/Microsoft.DotNet.MSBuildSdkResolver.csproj b/src/Microsoft.DotNet.MSBuildSdkResolver/Microsoft.DotNet.MSBuildSdkResolver.csproj new file mode 100644 index 000000000..335eed3ce --- /dev/null +++ b/src/Microsoft.DotNet.MSBuildSdkResolver/Microsoft.DotNet.MSBuildSdkResolver.csproj @@ -0,0 +1,39 @@ + + + + + $(SdkVersion) + netstandard1.3;net46 + netstandard1.3 + AnyCPU + win-x86;win-x64 + true + ../../tools/Key.snk + true + true + false + $(SdkResolverOutputDirectory) + + + + + + + + + + + + + + + x86/hostfxr.dll + PreserveNewest + + + x64/hostfxr.dll + PreserveNewest + + + + diff --git a/src/Microsoft.DotNet.MSBuildSdkResolver/Microsoft.DotNet.MSBuildSdkResolver.sln b/src/Microsoft.DotNet.MSBuildSdkResolver/Microsoft.DotNet.MSBuildSdkResolver.sln new file mode 100644 index 000000000..4d5062122 --- /dev/null +++ b/src/Microsoft.DotNet.MSBuildSdkResolver/Microsoft.DotNet.MSBuildSdkResolver.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26425.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.MSBuildSdkResolver", "Microsoft.DotNet.MSBuildSdkResolver.csproj", "{DCB2A518-7BC6-43F5-BE2C-13B11A1F3961}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.MSBuildSdkResolver.Tests", "..\..\test\Microsoft.DotNet.MSBuildSdkResolver.Tests\Microsoft.DotNet.MSBuildSdkResolver.Tests.csproj", "{CC488F39-E106-4BF4-9599-19A265AFD9AC}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DCB2A518-7BC6-43F5-BE2C-13B11A1F3961}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DCB2A518-7BC6-43F5-BE2C-13B11A1F3961}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DCB2A518-7BC6-43F5-BE2C-13B11A1F3961}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DCB2A518-7BC6-43F5-BE2C-13B11A1F3961}.Release|Any CPU.Build.0 = Release|Any CPU + {CC488F39-E106-4BF4-9599-19A265AFD9AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CC488F39-E106-4BF4-9599-19A265AFD9AC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CC488F39-E106-4BF4-9599-19A265AFD9AC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CC488F39-E106-4BF4-9599-19A265AFD9AC}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/src/dotnet-archive/Program.cs b/src/dotnet-archive/Program.cs deleted file mode 100644 index 3376bf47e..000000000 --- a/src/dotnet-archive/Program.cs +++ /dev/null @@ -1,96 +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 Microsoft.DotNet.Cli.CommandLine; -//using Microsoft.DotNet.Cli.Utils; -using Microsoft.DotNet.Archive; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Reflection; - -namespace Microsoft.DotNet.Tools.Archive -{ - - public partial class ArchiveCommand - { - public static int Main(string[] args) - { - //DebugHelper.HandleDebugSwitch(ref args); - - var app = new CommandLineApplication(); - app.Name = "archive"; - app.FullName = ".NET archiver"; - app.Description = "Archives and expands sets of files"; - app.HelpOption("-h|--help"); - - var extract = app.Option("-x|--extract ", "Directory to extract to", CommandOptionType.SingleValue); - var archiveFile = app.Option("-a|--archive ", "Archive to operate on", CommandOptionType.SingleValue); - var externals = app.Option("--external ...", "External files and directories to consider for extraction", CommandOptionType.MultipleValue); - var sources = app.Argument("...", "Files & directory to include in the archive", multipleValues:true); - - app.OnExecute(() => { - - if (extract.HasValue() && sources.Values.Any()) - { - Console.WriteLine("Extract '-x' can only be specified when no '' are specified to add to the archive."); - return 1; - } - else if (!extract.HasValue() && !sources.Values.Any()) - { - Console.WriteLine("Either extract '-x' or '' must be specified."); - return 1; - } - - if (!archiveFile.HasValue()) - { - Console.WriteLine("Archive '-a' must be specified."); - return 1; - } - - var progress = new ConsoleProgressReport(); - - var archive = new IndexedArchive(); - foreach (var external in externals.Values) - { - if (Directory.Exists(external)) - { - archive.AddExternalDirectory(external); - } - else - { - archive.AddExternalFile(external); - } - } - - if (sources.Values.Any()) - { - foreach(var source in sources.Values) - { - if (Directory.Exists(source)) - { - archive.AddDirectory(source, progress); - } - else - { - archive.AddFile(source, Path.GetFileName(source)); - } - } - - archive.Save(archiveFile.Value(), progress); - } - else // sources not specified, extract must have been specified - { - archive.Extract(archiveFile.Value(), extract.Value(), progress); - - } - - return 0; - }); - - return app.Execute(args); - } - } -} diff --git a/src/dotnet-archive/dotnet-archive.csproj b/src/dotnet-archive/dotnet-archive.csproj deleted file mode 100644 index a983cefce..000000000 --- a/src/dotnet-archive/dotnet-archive.csproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - - $(CliTargetFramework) - Exe - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/dotnet/ForwardingApp.cs b/src/dotnet/ForwardingApp.cs index 2ae292b75..25d3cff58 100644 --- a/src/dotnet/ForwardingApp.cs +++ b/src/dotnet/ForwardingApp.cs @@ -1,28 +1,17 @@ // 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 Microsoft.DotNet.Cli.Utils; +using System; using System.Collections.Generic; using System.Diagnostics; -using Microsoft.DotNet.Cli.Utils; +using System.Text; namespace Microsoft.DotNet.Cli { - /// - /// A class which encapsulates logic needed to forward arguments from the current process to another process - /// invoked with the dotnet.exe host. - /// public class ForwardingApp { - private const string s_hostExe = "dotnet"; - - private readonly string _forwardApplicationPath; - private readonly IEnumerable _argsToForward; - private readonly string _depsFile; - private readonly string _runtimeConfig; - private readonly string _additionalProbingPath; - private Dictionary _environmentVariables; - - private readonly string[] _allArgs; + private ForwardingAppImplementation _implementation; public ForwardingApp( string forwardApplicationPath, @@ -32,77 +21,29 @@ namespace Microsoft.DotNet.Cli string additionalProbingPath = null, Dictionary environmentVariables = null) { - _forwardApplicationPath = forwardApplicationPath; - _argsToForward = argsToForward; - _depsFile = depsFile; - _runtimeConfig = runtimeConfig; - _additionalProbingPath = additionalProbingPath; - _environmentVariables = environmentVariables; - - var allArgs = new List(); - allArgs.Add("exec"); - - if (_depsFile != null) - { - allArgs.Add("--depsfile"); - allArgs.Add(_depsFile); - } - - if (_runtimeConfig != null) - { - allArgs.Add("--runtimeconfig"); - allArgs.Add(_runtimeConfig); - } - - if (_additionalProbingPath != null) - { - allArgs.Add("--additionalprobingpath"); - allArgs.Add(_additionalProbingPath); - } - - allArgs.Add(_forwardApplicationPath); - allArgs.AddRange(_argsToForward); - - _allArgs = allArgs.ToArray(); - } - - public int Execute() - { - return GetProcessStartInfo().Execute(); + _implementation = new ForwardingAppImplementation( + forwardApplicationPath, + argsToForward, + depsFile, + runtimeConfig, + additionalProbingPath, + environmentVariables); } public ProcessStartInfo GetProcessStartInfo() { - var processInfo = new ProcessStartInfo - { - FileName = GetHostExeName(), - Arguments = ArgumentEscaper.EscapeAndConcatenateArgArrayForProcessStart(_allArgs), - UseShellExecute = false - }; - - if (_environmentVariables != null) - { - foreach (var entry in _environmentVariables) - { - processInfo.Environment[entry.Key] = entry.Value; - } - } - - return processInfo; + return _implementation.GetProcessStartInfo(); } public ForwardingApp WithEnvironmentVariable(string name, string value) { - _environmentVariables = _environmentVariables ?? new Dictionary(); - - _environmentVariables.Add(name, value); - + _implementation = _implementation.WithEnvironmentVariable(name, value); return this; } - private string GetHostExeName() + public int Execute() { - return $"{s_hostExe}{FileNameSuffixes.CurrentPlatform.Exe}"; + return _implementation.Execute(); } } } diff --git a/src/dotnet/NuGetForwardingApp.cs b/src/dotnet/NuGetForwardingApp.cs index 04e86623a..bf5852f75 100644 --- a/src/dotnet/NuGetForwardingApp.cs +++ b/src/dotnet/NuGetForwardingApp.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.IO; using Microsoft.DotNet.Cli; +using Microsoft.DotNet.Cli.Utils; namespace Microsoft.DotNet.Tools { diff --git a/src/dotnet/ProcessStartInfoExtensions.cs b/src/dotnet/ProcessStartInfoExtensions.cs deleted file mode 100644 index cb8e0de83..000000000 --- a/src/dotnet/ProcessStartInfoExtensions.cs +++ /dev/null @@ -1,29 +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; -using System.Diagnostics; - -namespace Microsoft.DotNet.Cli -{ - internal static class ProcessStartInfoExtensions - { - public static int Execute(this ProcessStartInfo startInfo) - { - if (startInfo == null) - { - throw new ArgumentNullException(nameof(startInfo)); - } - - var process = new Process - { - StartInfo = startInfo - }; - - process.Start(); - process.WaitForExit(); - - return process.ExitCode; - } - } -} diff --git a/src/dotnet/commands/dotnet-msbuild/MSBuildForwardingApp.cs b/src/dotnet/commands/dotnet-msbuild/MSBuildForwardingApp.cs index 78b2e5861..b3edf4abe 100644 --- a/src/dotnet/commands/dotnet-msbuild/MSBuildForwardingApp.cs +++ b/src/dotnet/commands/dotnet-msbuild/MSBuildForwardingApp.cs @@ -10,6 +10,7 @@ using System.Runtime.InteropServices; using Microsoft.DotNet.Cli; using Microsoft.DotNet.Cli.CommandLine; using System.Diagnostics; +using Microsoft.DotNet.Cli.Utils; namespace Microsoft.DotNet.Tools.MSBuild { @@ -17,24 +18,9 @@ namespace Microsoft.DotNet.Tools.MSBuild { internal const string TelemetrySessionIdEnvironmentVariableName = "DOTNET_CLI_TELEMETRY_SESSIONID"; - private const string MSBuildExeName = "MSBuild.dll"; + private MSBuildForwardingAppWithoutLogging _forwardingAppWithoutLogging; - private const string SdksDirectoryName = "Sdks"; - - private readonly ForwardingApp _forwardingApp; - - private readonly Dictionary _msbuildRequiredEnvironmentVariables = - new Dictionary - { - { "MSBuildExtensionsPath", AppContext.BaseDirectory }, - { "CscToolExe", GetRunCscPath() }, - { "MSBuildSDKsPath", GetMSBuildSDKsPath() } - }; - - private readonly IEnumerable _msbuildRequiredParameters = - new List { "/m", "/v:m" }; - - public MSBuildForwardingApp(IEnumerable argsToForward, string msbuildPath = null) + private static IEnumerable ConcatTelemetryLogger(IEnumerable argsToForward) { if (Telemetry.CurrentSessionId != null) { @@ -42,7 +28,7 @@ namespace Microsoft.DotNet.Tools.MSBuild { Type loggerType = typeof(MSBuildLogger); - argsToForward = argsToForward + return argsToForward .Concat(new[] { $"/Logger:{loggerType.FullName},{loggerType.GetTypeInfo().Assembly.Location}" @@ -53,57 +39,28 @@ namespace Microsoft.DotNet.Tools.MSBuild // Exceptions during telemetry shouldn't cause anything else to fail } } + return argsToForward; + } - _forwardingApp = new ForwardingApp( - msbuildPath ?? GetMSBuildExePath(), - _msbuildRequiredParameters.Concat(argsToForward.Select(Escape)), - environmentVariables: _msbuildRequiredEnvironmentVariables); + public MSBuildForwardingApp(IEnumerable argsToForward, string msbuildPath = null) + { + _forwardingAppWithoutLogging = new MSBuildForwardingAppWithoutLogging( + ConcatTelemetryLogger(argsToForward), + msbuildPath); } public ProcessStartInfo GetProcessStartInfo() { - return _forwardingApp - .WithEnvironmentVariable(TelemetrySessionIdEnvironmentVariableName, Telemetry.CurrentSessionId) - .GetProcessStartInfo(); + var ret = _forwardingAppWithoutLogging.GetProcessStartInfo(); + + ret.Environment[TelemetrySessionIdEnvironmentVariableName] = Telemetry.CurrentSessionId; + + return ret; } public int Execute() { return GetProcessStartInfo().Execute(); } - - private static string Escape(string arg) => - // this is a workaround for https://github.com/Microsoft/msbuild/issues/1622 - (arg.StartsWith("/p:RestoreSources=", StringComparison.OrdinalIgnoreCase)) ? - arg.Replace(";", "%3B") - .Replace("://", ":%2F%2F") : - arg; - - private static string GetMSBuildExePath() - { - return Path.Combine( - AppContext.BaseDirectory, - MSBuildExeName); - } - - private static string GetMSBuildSDKsPath() - { - var envMSBuildSDKsPath = Environment.GetEnvironmentVariable("MSBuildSDKsPath"); - - if (envMSBuildSDKsPath != null) - { - return envMSBuildSDKsPath; - } - - return Path.Combine( - AppContext.BaseDirectory, - SdksDirectoryName); - } - - private static string GetRunCscPath() - { - var scriptExtension = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".cmd" : ".sh"; - return Path.Combine(AppContext.BaseDirectory, "Roslyn", $"RunCsc{scriptExtension}"); - } } } diff --git a/src/dotnet/commands/dotnet-new/NewCommandShim.cs b/src/dotnet/commands/dotnet-new/NewCommandShim.cs index bc06185cc..6e36fd9c0 100644 --- a/src/dotnet/commands/dotnet-new/NewCommandShim.cs +++ b/src/dotnet/commands/dotnet-new/NewCommandShim.cs @@ -29,13 +29,14 @@ namespace Microsoft.DotNet.Tools.New { var sessionId = Environment.GetEnvironmentVariable(MSBuildForwardingApp.TelemetrySessionIdEnvironmentVariableName); var telemetry = new Telemetry(new NuGetCacheSentinel(new CliFallbackFolderPathCalculator()), sessionId); - var logger = new TelemetryLogger((name, props, measures) => - { - if (telemetry.Enabled) - { - telemetry.TrackEvent(name, props, measures); - } - }); + var logger = new TelemetryLogger(null); + //(name, props, measures) => + //{ + // if (telemetry.Enabled) + // { + // telemetry.TrackEvent(name, props, measures); + // } + //}); return New3Command.Run(CommandName, CreateHost(), logger, FirstRun, args); } diff --git a/src/dotnet/commands/dotnet-test/LocalizableStrings.cs b/src/dotnet/commands/dotnet-test/LocalizableStrings.cs index 6056e0fc2..fbe9ba5c0 100644 --- a/src/dotnet/commands/dotnet-test/LocalizableStrings.cs +++ b/src/dotnet/commands/dotnet-test/LocalizableStrings.cs @@ -37,7 +37,8 @@ namespace Microsoft.DotNet.Tools.Test public const string CmdLoggerOption = "LoggerUri/FriendlyName"; public const string CmdLoggerDescription = @"Specify a logger for test results. - Example: --logger ""trx[;LogFileName=]"""; + Example: --logger ""trx[;LogFileName=]"" + More info on logger arguments support:https://aka.ms/vstest-report"; public const string CmdConfiguration = "CONFIGURATION"; @@ -58,12 +59,22 @@ namespace Microsoft.DotNet.Tools.Test public const string CmdNoBuildDescription = @"Do not build project before testing."; - public const string RunSettingsArgsHelpText = @"Any extra command-line runsettings arguments that should be passed to vstest. See 'dotnet vstest --help' for available options. - Example: -- RunConfiguration.ResultsDirectory=""C:\users\user\desktop\Results Directory"" MSTest.DeploymentEnabled=false"; - public const string CmdResultsDirectoryDescription = @"The directory where the test results are going to be placed. The specified directory will be created if it does not exist. Example: --results-directory "; public const string CmdPathToResultsDirectory = "PATH_TO_RESULTS_DIRECTORY"; + + public const string RunSettingsArgumentsDescription = @" + +RunSettings arguments: + Arguments to pass runsettings configurations through commandline. Arguments may be specified as name-value pair of the form [name]=[value] after ""-- "". Note the space after --. + Use a space to separate multiple[name] =[value]. + More info on RunSettings arguments support: https://aka.ms/vstest-runsettings-arguments + Example: dotnet test -- MSTest.DeploymentEnabled=false MSTest.MapInconclusiveToFailed=True"; + + public const string cmdCollectFriendlyName = "DATA_COLLECTOR_FRIENDLY_NAME"; + + public const string cmdCollectDescription = @"Enables data collector for the test run. + More info here : https://aka.ms/vstest-collect"; } } diff --git a/src/dotnet/commands/dotnet-test/Program.cs b/src/dotnet/commands/dotnet-test/Program.cs index 913181a20..a7f9a0380 100644 --- a/src/dotnet/commands/dotnet-test/Program.cs +++ b/src/dotnet/commands/dotnet-test/Program.cs @@ -21,7 +21,7 @@ namespace Microsoft.DotNet.Tools.Test { } - public static TestCommand FromArgs(string[] args, string msbuildPath=null) + public static TestCommand FromArgs(string[] args, string msbuildPath = null) { var msbuildArgs = new List() { @@ -34,6 +34,7 @@ namespace Microsoft.DotNet.Tools.Test var result = parser.ParseFrom("dotnet test", args); + UpdateRunSettingsArgumentsText(); result.ShowHelpOrErrorIfAppropriate(); var parsedTest = result["dotnet"]["test"]; @@ -42,7 +43,7 @@ namespace Microsoft.DotNet.Tools.Test msbuildArgs.AddRange(parsedTest.Arguments); - var runSettingsOptions = + var runSettingsOptions = result.UnparsedTokens .Select(GetSemiColonEscapedString); @@ -53,6 +54,17 @@ namespace Microsoft.DotNet.Tools.Test msbuildArgs.Add($"/p:VSTestCLIRunSettings=\"{runSettingsArg}\""); } + var verbosityArg = msbuildArgs.LastOrDefault(arg => arg.StartsWith("/verbosity")); + + if (!string.IsNullOrEmpty(verbosityArg)) + { + var verbosity = verbosityArg.Split(':'); + if (verbosity.Length == 2) + { + msbuildArgs.Add($"/p:VSTestVerbosity={verbosity[1]}"); + } + } + return new TestCommand(msbuildArgs, msbuildPath); } @@ -61,7 +73,7 @@ namespace Microsoft.DotNet.Tools.Test DebugHelper.HandleDebugSwitch(ref args); TestCommand cmd; - + try { cmd = FromArgs(args); @@ -96,5 +108,11 @@ namespace Microsoft.DotNet.Tools.Test return array; } + + private static void UpdateRunSettingsArgumentsText() + { + DefaultHelpViewText.Synopsis.AdditionalArguments = " [[--] ...]]"; + DefaultHelpViewText.AdditionalArgumentsSection = LocalizableStrings.RunSettingsArgumentsDescription; + } } } diff --git a/src/dotnet/commands/dotnet-test/TestCommandParser.cs b/src/dotnet/commands/dotnet-test/TestCommandParser.cs index c79dee524..a17aa20a7 100644 --- a/src/dotnet/commands/dotnet-test/TestCommandParser.cs +++ b/src/dotnet/commands/dotnet-test/TestCommandParser.cs @@ -14,6 +14,7 @@ namespace Microsoft.DotNet.Cli Accept.ZeroOrMoreArguments() .With(name: LocalizableStrings.CmdArgProject, description: LocalizableStrings.CmdArgDescription), + false, CommonOptions.HelpOption(), Create.Option( "-s|--settings", @@ -74,6 +75,12 @@ namespace Microsoft.DotNet.Cli Accept.ExactlyOneArgument() .With(name: LocalizableStrings.CmdPathToResultsDirectory) .ForwardAsSingle(o => $"/p:VSTestResultsDirectory={o.Arguments.Single()}")), + Create.Option( + "--collect", + LocalizableStrings.cmdCollectDescription, + Accept.OneOrMoreArguments() + .With(name: LocalizableStrings.cmdCollectFriendlyName) + .ForwardAsSingle(o => $"/p:VSTestCollect=\"{string.Join(";", o.Arguments)}\"")), CommonOptions.VerbosityOption()); private static string GetSemiColonEsacpedstring(string arg) diff --git a/src/redist/redist.csproj b/src/redist/redist.csproj index 8175929d7..02b89f3cb 100644 --- a/src/redist/redist.csproj +++ b/src/redist/redist.csproj @@ -32,6 +32,17 @@
+ + + + + + + + + @@ -150,6 +161,7 @@ diff --git a/test/EndToEnd/GivenDotNetUsesMSBuild.cs b/test/EndToEnd/GivenDotNetUsesMSBuild.cs index 86d19e0c3..f714ee38c 100644 --- a/test/EndToEnd/GivenDotNetUsesMSBuild.cs +++ b/test/EndToEnd/GivenDotNetUsesMSBuild.cs @@ -89,7 +89,7 @@ namespace Microsoft.DotNet.Tests.EndToEnd .And.HaveStdOutContaining("Hello I prefer the cli runtime World!");; } - [RequiresSpecificFrameworkFact("netcoreapp1.1")] // https://github.com/dotnet/cli/issues/6087 + [Fact] public void ItCanRunAToolThatInvokesADependencyToolInACSProj() { var repoDirectoriesProvider = new RepoDirectoriesProvider(); diff --git a/test/Microsoft.DotNet.Cli.Tests.sln b/test/Microsoft.DotNet.Cli.Tests.sln index 78f638f4a..370d70331 100644 --- a/test/Microsoft.DotNet.Cli.Tests.sln +++ b/test/Microsoft.DotNet.Cli.Tests.sln @@ -76,6 +76,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnet-back-compat.Tests", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dotnet-remove-package.Tests", "dotnet-remove-package.Tests\dotnet-remove-package.Tests.csproj", "{CF517B15-B307-4660-87D5-CC036ADECD4B}" EndProject +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.MSBuildSdkResolver.Tests", "Microsoft.DotNet.MSBuildSdkResolver.Tests\Microsoft.DotNet.MSBuildSdkResolver.Tests.csproj", "{42A0CAB4-FFAD-47D4-9880-C0F4EDCF93DE}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -494,6 +497,18 @@ Global {CF517B15-B307-4660-87D5-CC036ADECD4B}.Release|x64.Build.0 = Release|x64 {CF517B15-B307-4660-87D5-CC036ADECD4B}.Release|x86.ActiveCfg = Release|x86 {CF517B15-B307-4660-87D5-CC036ADECD4B}.Release|x86.Build.0 = Release|x86 + {42A0CAB4-FFAD-47D4-9880-C0F4EDCF93DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {42A0CAB4-FFAD-47D4-9880-C0F4EDCF93DE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {42A0CAB4-FFAD-47D4-9880-C0F4EDCF93DE}.Debug|x64.ActiveCfg = Debug|Any CPU + {42A0CAB4-FFAD-47D4-9880-C0F4EDCF93DE}.Debug|x64.Build.0 = Debug|Any CPU + {42A0CAB4-FFAD-47D4-9880-C0F4EDCF93DE}.Debug|x86.ActiveCfg = Debug|Any CPU + {42A0CAB4-FFAD-47D4-9880-C0F4EDCF93DE}.Debug|x86.Build.0 = Debug|Any CPU + {42A0CAB4-FFAD-47D4-9880-C0F4EDCF93DE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {42A0CAB4-FFAD-47D4-9880-C0F4EDCF93DE}.Release|Any CPU.Build.0 = Release|Any CPU + {42A0CAB4-FFAD-47D4-9880-C0F4EDCF93DE}.Release|x64.ActiveCfg = Release|Any CPU + {42A0CAB4-FFAD-47D4-9880-C0F4EDCF93DE}.Release|x64.Build.0 = Release|Any CPU + {42A0CAB4-FFAD-47D4-9880-C0F4EDCF93DE}.Release|x86.ActiveCfg = Release|Any CPU + {42A0CAB4-FFAD-47D4-9880-C0F4EDCF93DE}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/test/Microsoft.DotNet.Cli.Utils.Tests/GivenAProjectToolsCommandResolver.cs b/test/Microsoft.DotNet.Cli.Utils.Tests/GivenAProjectToolsCommandResolver.cs index 938ad5075..11eca166a 100644 --- a/test/Microsoft.DotNet.Cli.Utils.Tests/GivenAProjectToolsCommandResolver.cs +++ b/test/Microsoft.DotNet.Cli.Utils.Tests/GivenAProjectToolsCommandResolver.cs @@ -281,7 +281,8 @@ namespace Microsoft.DotNet.Tests lockFile, s_toolPackageFramework, depsJsonFile, - new SingleProjectInfo("dotnet-portable", "1.0.0", Enumerable.Empty())); + new SingleProjectInfo("dotnet-portable", "1.0.0", Enumerable.Empty()), + GetToolDepsJsonGeneratorProject()); File.ReadAllText(depsJsonFile).Should().Be("temp"); File.Delete(depsJsonFile); @@ -456,5 +457,12 @@ namespace Microsoft.DotNet.Tests return projectToolsCommandResolver; } + + private string GetToolDepsJsonGeneratorProject() + { + // When using the product, the ToolDepsJsonGeneratorProject property is used to get this path, but for testing + // we'll hard code the path inside the SDK since we don't have a project to evaluate here + return Path.Combine(new RepoDirectoriesProvider().Stage2Sdk, "Sdks", "Microsoft.NET.Sdk", "build", "GenerateDeps", "GenerateDeps.proj"); + } } } diff --git a/test/Microsoft.DotNet.Cli.Utils.Tests/GivenAppThrowingException.cs b/test/Microsoft.DotNet.Cli.Utils.Tests/GivenAppThrowingException.cs index e5da522f8..1470e6d78 100644 --- a/test/Microsoft.DotNet.Cli.Utils.Tests/GivenAppThrowingException.cs +++ b/test/Microsoft.DotNet.Cli.Utils.Tests/GivenAppThrowingException.cs @@ -10,7 +10,7 @@ namespace Microsoft.DotNet.Cli.Utils.Tests { public class GivenAppThrowingException : TestBase { - [Fact] + [RequiresSpecificFrameworkFact("netcoreapp1.1")] public void ItShowsStackTraceWhenRun() { var root = TestAssets.Get("NonRestoredTestProjects", "AppThrowingException") @@ -28,15 +28,15 @@ namespace Microsoft.DotNet.Cli.Utils.Tests string msg1 = "Unhandled Exception: AppThrowing.MyException: " + "Exception of type 'AppThrowing.MyException' was thrown."; string msg2 = "at AppThrowing.MyException.Main(String[] args)"; - new RunCommand() + new DotnetCommand(DotnetUnderTest.WithBackwardsCompatibleRuntimes) .WithWorkingDirectory(appRoot) - .ExecuteWithCapturedOutput() + .ExecuteWithCapturedOutput("run") .Should().Fail() .And.HaveStdErrContaining(msg1) .And.HaveStdErrContaining(msg2); } - [Fact] + [RequiresSpecificFrameworkFact("netcoreapp1.1")] public void ItShowsStackTraceWhenRunAsTool() { var root = TestAssets.Get("NonRestoredTestProjects", "AppThrowingException") @@ -67,7 +67,7 @@ namespace Microsoft.DotNet.Cli.Utils.Tests string msg1 = "Unhandled Exception: AppThrowing.MyException: " + "Exception of type 'AppThrowing.MyException' was thrown."; string msg2 = "at AppThrowing.MyException.Main(String[] args)"; - new DotnetCommand() + new DotnetCommand(DotnetUnderTest.WithBackwardsCompatibleRuntimes) .WithWorkingDirectory(appWithToolDepRoot) .ExecuteWithCapturedOutput("throwingtool") .Should().Fail() diff --git a/test/Microsoft.DotNet.MSBuildSdkResolver.Tests/GivenAnMSBuildSdkResolver.cs b/test/Microsoft.DotNet.MSBuildSdkResolver.Tests/GivenAnMSBuildSdkResolver.cs new file mode 100644 index 000000000..bfbf14e4a --- /dev/null +++ b/test/Microsoft.DotNet.MSBuildSdkResolver.Tests/GivenAnMSBuildSdkResolver.cs @@ -0,0 +1,70 @@ +// 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.Collections.Generic; +using Microsoft.Build.Framework; +using Xunit; +using System.Linq; +using Xunit.Abstractions; +using System; +using Microsoft.DotNet.MSBuildSdkResolver; + +namespace Microsoft.DotNet.Cli.Utils.Tests +{ + public class GivenAnMSBuildSdkResolver + { + private ITestOutputHelper _logger; + + public GivenAnMSBuildSdkResolver(ITestOutputHelper logger) + { + _logger = logger; + } + + [Fact] + public void ItHasCorrectNameAndPriority() + { + var resolver = new DotNetMSBuildSdkResolver(); + + Assert.Equal(5000, resolver.Priority); + Assert.Equal("Microsoft.DotNet.MSBuildSdkResolver", resolver.Name); + } + + [Fact] + public void ItCallsNativeCodeWithoutCrashing() // WIP: placeholder to get plumbing through + { + var resolver = new DotNetMSBuildSdkResolver(); + var result = (MockResult)resolver.Resolve( + new SdkReference("Microsoft.NET.Sdk", null, null), + new MockContext(), + new MockFactory()); + + _logger.WriteLine($"success: {result.Success}"); + _logger.WriteLine($"errors: {string.Join(Environment.NewLine, result.Errors ?? Array.Empty())}"); + _logger.WriteLine($"warnings: {string.Join(Environment.NewLine, result.Warnings ?? Array.Empty())}"); + _logger.WriteLine($"path: {result.Path}"); + _logger.WriteLine($"version: {result.Version}"); + } + + private sealed class MockContext : SdkResolverContext + { + } + + private sealed class MockFactory : SdkResultFactory + { + public override SdkResult IndicateFailure(IEnumerable errors, IEnumerable warnings = null) + => new MockResult { Success = false, Errors = errors, Warnings = warnings }; + + public override SdkResult IndicateSuccess(string path, string version, IEnumerable warnings = null) + => new MockResult { Success = true, Path = path, Version = version, Warnings = warnings }; + } + + private sealed class MockResult : SdkResult + { + public new bool Success { get => base.Success; set => base.Success = value; } + public string Version { get; set; } + public string Path { get; set; } + public IEnumerable Errors { get; set; } + public IEnumerable Warnings { get; set; } + } + } +} diff --git a/test/Microsoft.DotNet.MSBuildSdkResolver.Tests/Microsoft.DotNet.MSBuildSdkResolver.Tests.csproj b/test/Microsoft.DotNet.MSBuildSdkResolver.Tests/Microsoft.DotNet.MSBuildSdkResolver.Tests.csproj new file mode 100644 index 000000000..bfc8f571a --- /dev/null +++ b/test/Microsoft.DotNet.MSBuildSdkResolver.Tests/Microsoft.DotNet.MSBuildSdkResolver.Tests.csproj @@ -0,0 +1,30 @@ + + + + + net46;$(CliTargetFramework) + $(CliTargetFramework) + $(CLI_SharedFrameworkVersion) + Exe + ../../tools/Key.snk + true + true + + + + + + + + + + + + + + + + + + + diff --git a/test/Microsoft.DotNet.MSBuildSdkResolver.Tests/xunit.runner.json b/test/Microsoft.DotNet.MSBuildSdkResolver.Tests/xunit.runner.json new file mode 100644 index 000000000..34b2fe2cd --- /dev/null +++ b/test/Microsoft.DotNet.MSBuildSdkResolver.Tests/xunit.runner.json @@ -0,0 +1,3 @@ +{ + "shadowCopy": false +} \ No newline at end of file diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/RequiresSpecificFrameworkTheoryAttribute.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/RequiresSpecificFrameworkTheoryAttribute.cs new file mode 100644 index 000000000..52166156b --- /dev/null +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/RequiresSpecificFrameworkTheoryAttribute.cs @@ -0,0 +1,22 @@ +// 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 Microsoft.DotNet.Tools.Test.Utilities; +using System; +using System.Collections.Generic; +using System.Text; +using Xunit; + +namespace Microsoft.DotNet.Tools.Test.Utilities +{ + public class RequiresSpecificFrameworkTheoryAttribute : TheoryAttribute + { + public RequiresSpecificFrameworkTheoryAttribute(string framework) + { + if (!EnvironmentInfo.HasSharedFramework(framework)) + { + this.Skip = $"This test requires a shared framework that isn't present: {framework}"; + } + } + } +} diff --git a/test/dotnet-back-compat.Tests/GivenThatWeWantToBeBackwardsCompatibleWith1xProjects.cs b/test/dotnet-back-compat.Tests/GivenThatWeWantToBeBackwardsCompatibleWith1xProjects.cs index 30ecc1f38..e41cf2c8e 100644 --- a/test/dotnet-back-compat.Tests/GivenThatWeWantToBeBackwardsCompatibleWith1xProjects.cs +++ b/test/dotnet-back-compat.Tests/GivenThatWeWantToBeBackwardsCompatibleWith1xProjects.cs @@ -13,8 +13,7 @@ namespace Microsoft.DotNet.Cli.Build.Tests { public class GivenThatWeWantToBeBackwardsCompatibleWith1xProjects : TestBase { - [Theory] - [InlineData("netcoreapp1.0")] + [RequiresSpecificFrameworkTheory("netcoreapp1.1")] [InlineData("netcoreapp1.1")] public void ItRestoresBuildsAndRuns(string target) { diff --git a/test/dotnet-migrate.Tests/NuGet.tempaspnetpatch.config b/test/dotnet-migrate.Tests/NuGet.tempaspnetpatch.config index eaf5b585e..33b9693d5 100644 --- a/test/dotnet-migrate.Tests/NuGet.tempaspnetpatch.config +++ b/test/dotnet-migrate.Tests/NuGet.tempaspnetpatch.config @@ -3,11 +3,9 @@ - - - - - + + + \ No newline at end of file diff --git a/test/dotnet-msbuild.Tests/GivenDotnetMSBuildBuildsProjects.cs b/test/dotnet-msbuild.Tests/GivenDotnetMSBuildBuildsProjects.cs index 41622c72f..51e7017b1 100644 --- a/test/dotnet-msbuild.Tests/GivenDotnetMSBuildBuildsProjects.cs +++ b/test/dotnet-msbuild.Tests/GivenDotnetMSBuildBuildsProjects.cs @@ -14,6 +14,8 @@ using NuGet.Protocol; using Xunit; using Xunit.Abstractions; using MSBuildCommand = Microsoft.DotNet.Tools.Test.Utilities.MSBuildCommand; +using System.Diagnostics; +using System.Threading; namespace Microsoft.DotNet.Cli.MSBuild.Tests { @@ -164,11 +166,16 @@ namespace Microsoft.DotNet.Cli.MSBuild.Tests MSBuildForwardingApp msBuildForwardingApp = new MSBuildForwardingApp(Enumerable.Empty()); - FieldInfo forwardingAppFieldInfo = msBuildForwardingApp + object forwardingAppWithoutLogging = msBuildForwardingApp + .GetType() + .GetField("_forwardingAppWithoutLogging", BindingFlags.Instance | BindingFlags.NonPublic) + ?.GetValue(msBuildForwardingApp); + + FieldInfo forwardingAppFieldInfo = forwardingAppWithoutLogging .GetType() .GetField("_forwardingApp", BindingFlags.Instance | BindingFlags.NonPublic); - ForwardingApp forwardingApp = forwardingAppFieldInfo?.GetValue(msBuildForwardingApp) as ForwardingApp; + object forwardingApp = forwardingAppFieldInfo?.GetValue(forwardingAppWithoutLogging); FieldInfo allArgsFieldinfo = forwardingApp? .GetType() diff --git a/test/dotnet-new.Tests/NuGet.tempaspnetpatch.config b/test/dotnet-new.Tests/NuGet.tempaspnetpatch.config index 80a6898ca..33b9693d5 100644 --- a/test/dotnet-new.Tests/NuGet.tempaspnetpatch.config +++ b/test/dotnet-new.Tests/NuGet.tempaspnetpatch.config @@ -3,10 +3,9 @@ - - - - + + + \ No newline at end of file diff --git a/test/dotnet-restore.Tests/GivenThatIWantToRestoreApp.cs b/test/dotnet-restore.Tests/GivenThatIWantToRestoreApp.cs index 6b6f1b6b9..3b5c44b42 100644 --- a/test/dotnet-restore.Tests/GivenThatIWantToRestoreApp.cs +++ b/test/dotnet-restore.Tests/GivenThatIWantToRestoreApp.cs @@ -73,7 +73,7 @@ namespace Microsoft.DotNet.Restore.Tests [Fact] public void ItRestoresTestAppToSpecificDirectory() { - var rootPath = TestAssets.Get("VSTestDotNetCore").CreateInstance().WithSourceFiles().Root.FullName; + var rootPath = TestAssets.Get("VSTestCore").CreateInstance().WithSourceFiles().Root.FullName; string dir = "pkgs"; string fullPath = Path.GetFullPath(Path.Combine(rootPath, dir)); diff --git a/test/dotnet-store.Tests/GivenDotnetStoresAndPublishesProjects.cs b/test/dotnet-store.Tests/GivenDotnetStoresAndPublishesProjects.cs index d10dcca6b..e2845ec19 100644 --- a/test/dotnet-store.Tests/GivenDotnetStoresAndPublishesProjects.cs +++ b/test/dotnet-store.Tests/GivenDotnetStoresAndPublishesProjects.cs @@ -70,9 +70,9 @@ namespace Microsoft.DotNet.Cli.Publish.Tests [Fact] public void AppFailsDueToMissingCache() { - var testAppName = "NewtonSoftDependentProject"; - var profileProjectName = "NewtonsoftProfile"; - var targetManifestFileName = "NewtonsoftFilterProfile.xml"; + var testAppName = "NuGetConfigDependentProject"; + var profileProjectName = "NuGetConfigProfile"; + var targetManifestFileName = "NuGetConfigFilterProfile.xml"; var testInstance = TestAssets.Get(testAppName) .CreateInstance() @@ -102,7 +102,7 @@ namespace Microsoft.DotNet.Cli.Publish.Tests new DotnetCommand() .ExecuteWithCapturedOutput(outputDll) .Should().Fail() - .And.HaveStdErrContaining($"Error: assembly specified in the dependencies manifest was not found probably due to missing runtime store associated with {targetManifestFileName} -- package: 'Newtonsoft.Json',"); + .And.HaveStdErrContaining($"Error: assembly specified in the dependencies manifest was not found probably due to missing runtime store associated with {targetManifestFileName} -- package: 'NuGet.Configuration',"); } [Fact] diff --git a/test/dotnet-test.Tests/GivenDotnetTestBuildsAndRunsTestFromCsprojForMultipleTFM.cs b/test/dotnet-test.Tests/GivenDotnetTestBuildsAndRunsTestFromCsprojForMultipleTFM.cs index b6ee1198b..a111db3c3 100644 --- a/test/dotnet-test.Tests/GivenDotnetTestBuildsAndRunsTestFromCsprojForMultipleTFM.cs +++ b/test/dotnet-test.Tests/GivenDotnetTestBuildsAndRunsTestFromCsprojForMultipleTFM.cs @@ -12,11 +12,11 @@ namespace Microsoft.DotNet.Cli.Test.Tests { public class GivenDotnetTestBuildsAndRunsTestFromCsprojForMultipleTFM : TestBase { - [WindowsOnlyFact(Skip="https://github.com/dotnet/cli/issues/4616")] + [WindowsOnlyFact] public void MStestMultiTFM() { - var testProjectDirectory = TestAssets.Get("VSTestDesktopAndNetCore") - .CreateInstance() + var testProjectDirectory = TestAssets.Get("VSTestMulti") + .CreateInstance("1") .WithSourceFiles() .WithNuGetConfig(new RepoDirectoriesProvider().TestPackages) .Root; @@ -45,15 +45,15 @@ namespace Microsoft.DotNet.Cli.Test.Tests [WindowsOnlyFact] public void XunitMultiTFM() { - // Copy VSTestXunitDesktopAndNetCore project in output directory of project dotnet-test.Tests - string testAppName = "VSTestXunitDesktopAndNetCore"; + // Copy XunitMulti project in output directory of project dotnet-test.Tests + string testAppName = "XunitMulti"; var testInstance = TestAssets.Get(testAppName) - .CreateInstance() + .CreateInstance("2") .WithSourceFiles(); var testProjectDirectory = testInstance.Root.FullName; - // Restore project VSTestXunitDesktopAndNetCore + // Restore project XunitMulti new RestoreCommand() .WithWorkingDirectory(testProjectDirectory) .Execute() diff --git a/test/dotnet-test.Tests/GivenDotnetTestBuildsAndRunsTestfromCsproj.cs b/test/dotnet-test.Tests/GivenDotnetTestBuildsAndRunsTestfromCsproj.cs index c3630da20..b20fb70ef 100644 --- a/test/dotnet-test.Tests/GivenDotnetTestBuildsAndRunsTestfromCsproj.cs +++ b/test/dotnet-test.Tests/GivenDotnetTestBuildsAndRunsTestfromCsproj.cs @@ -17,20 +17,7 @@ namespace Microsoft.DotNet.Cli.Test.Tests [Fact] public void MSTestSingleTFM() { - // Copy VSTestDotNetCore project in output directory of project dotnet-vstest.Tests - string testAppName = "VSTestDotNetCore"; - var testInstance = TestAssets.Get(testAppName) - .CreateInstance() - .WithSourceFiles(); - - var testProjectDirectory = testInstance.Root.FullName; - - // Restore project VSTestDotNetCore - new RestoreCommand() - .WithWorkingDirectory(testProjectDirectory) - .Execute() - .Should() - .Pass(); + var testProjectDirectory = this.CopyAndRestoreVSTestDotNetCoreTestApp("3"); // Call test CommandResult result = new DotnetTestCommand() @@ -47,15 +34,15 @@ namespace Microsoft.DotNet.Cli.Test.Tests [Fact] public void XunitSingleTFM() { - // Copy VSTestXunitDotNetCore project in output directory of project dotnet-vstest.Tests - string testAppName = "VSTestXunitDotNetCore"; + // Copy XunitCore project in output directory of project dotnet-vstest.Tests + string testAppName = "XunitCore"; var testInstance = TestAssets.Get(testAppName) - .CreateInstance() + .CreateInstance("4") .WithSourceFiles(); var testProjectDirectory = testInstance.Root.FullName; - // Restore project VSTestXunitDotNetCore + // Restore project XunitCore new RestoreCommand() .WithWorkingDirectory(testProjectDirectory) .Execute() @@ -77,11 +64,11 @@ namespace Microsoft.DotNet.Cli.Test.Tests [Fact] public void TestWillNotBuildTheProjectIfNoBuildArgsIsGiven() { - // Copy and restore VSTestDotNetCore project in output directory of project dotnet-vstest.Tests - var testProjectDirectory = this.CopyAndRestoreVSTestDotNetCoreTestApp(); + // Copy and restore VSTestCore project in output directory of project dotnet-vstest.Tests + var testProjectDirectory = this.CopyAndRestoreVSTestDotNetCoreTestApp("5"); string configuration = Environment.GetEnvironmentVariable("CONFIGURATION") ?? "Debug"; string expectedError = Path.Combine(testProjectDirectory, "bin", - configuration, "netcoreapp2.0", "VSTestDotNetCore.dll"); + configuration, "netcoreapp2.0", "VSTestCore.dll"); expectedError = "The test source file " + "\"" + expectedError + "\"" + " provided was not found."; // Call test @@ -96,10 +83,10 @@ namespace Microsoft.DotNet.Cli.Test.Tests [Fact] public void TestWillCreateTrxLoggerInTheSpecifiedResultsDirectoryBySwitch() { - // Copy and restore VSTestDotNetCore project in output directory of project dotnet-vstest.Tests - var testProjectDirectory = this.CopyAndRestoreVSTestDotNetCoreTestApp(); + // Copy and restore VSTestCore project in output directory of project dotnet-vstest.Tests + var testProjectDirectory = this.CopyAndRestoreVSTestDotNetCoreTestApp("6"); - string trxLoggerDirectory = Path.Combine(testProjectDirectory, "TestResults", "netcoreappx.y"); + string trxLoggerDirectory = Path.Combine(testProjectDirectory, "TR", "x.y"); // Delete trxLoggerDirectory if it exist if (Directory.Exists(trxLoggerDirectory)) @@ -127,10 +114,10 @@ namespace Microsoft.DotNet.Cli.Test.Tests [Fact] public void ItCreatesTrxReportInTheSpecifiedResultsDirectoryByArgs() { - // Copy and restore VSTestDotNetCore project in output directory of project dotnet-vstest.Tests - var testProjectDirectory = this.CopyAndRestoreVSTestDotNetCoreTestApp(); + // Copy and restore VSTestCore project in output directory of project dotnet-vstest.Tests + var testProjectDirectory = this.CopyAndRestoreVSTestDotNetCoreTestApp("7"); - string trxLoggerDirectory = Path.Combine(testProjectDirectory, "ResultsDirectory"); + string trxLoggerDirectory = Path.Combine(testProjectDirectory, "RD"); // Delete trxLoggerDirectory if it exist if (Directory.Exists(trxLoggerDirectory)) @@ -155,12 +142,14 @@ namespace Microsoft.DotNet.Cli.Test.Tests } } - [Fact(Skip = "https://github.com/dotnet/cli/issues/5035")] + [Fact] public void ItBuildsAndTestsAppWhenRestoringToSpecificDirectory() { - var rootPath = TestAssets.Get("VSTestDotNetCore").CreateInstance().WithSourceFiles().Root.FullName; + // Creating folder with name short name "RestoreTest" to avoid PathTooLongException + var rootPath = TestAssets.Get("VSTestCore").CreateInstance("8").WithSourceFiles().Root.FullName; - string dir = "pkgs"; + // Moving pkgs folder on top to avoid PathTooLongException + string dir = @"..\..\..\..\pkgs"; string fullPath = Path.GetFullPath(Path.Combine(rootPath, dir)); string args = $"--packages \"{dir}\""; @@ -186,17 +175,35 @@ namespace Microsoft.DotNet.Cli.Test.Tests result.StdOut.Should().Contain("Failed TestNamespace.VSTestTests.VSTestFailTest"); } + [Fact] + public void ItUsesVerbosityPassedToDefineVerbosityOfConsoleLoggerOfTheTests() + { + // Copy and restore VSTestCore project in output directory of project dotnet-vstest.Tests + var testProjectDirectory = this.CopyAndRestoreVSTestDotNetCoreTestApp("9"); + + // Call test + CommandResult result = new DotnetTestCommand() + .WithWorkingDirectory(testProjectDirectory) + .ExecuteWithCapturedOutput("-v q"); + + // Verify + result.StdOut.Should().Contain("Total tests: 2. Passed: 1. Failed: 1. Skipped: 0."); + result.StdOut.Should().NotContain("Passed TestNamespace.VSTestTests.VSTestPassTest"); + result.StdOut.Should().NotContain("Failed TestNamespace.VSTestTests.VSTestFailTest"); + result.ExitCode.Should().Be(1); + } + private string CopyAndRestoreVSTestDotNetCoreTestApp([CallerMemberName] string callingMethod = "") { - // Copy VSTestDotNetCore project in output directory of project dotnet-vstest.Tests - string testAppName = "VSTestDotNetCore"; + // Copy VSTestCore project in output directory of project dotnet-vstest.Tests + string testAppName = "VSTestCore"; var testInstance = TestAssets.Get(testAppName) .CreateInstance(callingMethod) .WithSourceFiles(); var testProjectDirectory = testInstance.Root.FullName; - // Restore project VSTestDotNetCore + // Restore project VSTestCore new RestoreCommand() .WithWorkingDirectory(testProjectDirectory) .Execute() diff --git a/test/dotnet-vstest.Tests/VSTestTests.cs b/test/dotnet-vstest.Tests/VSTestTests.cs index cd7b0e8e9..0dba88ce5 100644 --- a/test/dotnet-vstest.Tests/VSTestTests.cs +++ b/test/dotnet-vstest.Tests/VSTestTests.cs @@ -16,7 +16,7 @@ namespace Microsoft.DotNet.Cli.VSTest.Tests [Fact] public void TestsFromAGivenContainerShouldRunWithExpectedOutput() { - var testAppName = "VSTestDotNetCore"; + var testAppName = "VSTestCore"; var testRoot = TestAssets.Get(testAppName) .CreateInstance() .WithSourceFiles() diff --git a/test/dotnet.Tests/PackagedCommandTests.cs b/test/dotnet.Tests/PackagedCommandTests.cs index e1816ca8f..d5c83d97a 100644 --- a/test/dotnet.Tests/PackagedCommandTests.cs +++ b/test/dotnet.Tests/PackagedCommandTests.cs @@ -16,6 +16,7 @@ using Xunit.Abstractions; using Microsoft.Build.Construction; using System.Linq; using Microsoft.Build.Evaluation; +using System.Xml.Linq; namespace Microsoft.DotNet.Tests { @@ -91,6 +92,132 @@ namespace Microsoft.DotNet.Tests .And.Pass(); } + [Theory] + [InlineData(true)] + [InlineData(false)] + public void IfPreviousVersionOfSharedFrameworkIsNotInstalled_ToolsTargetingItFail(bool toolPrefersCLIRuntime) + { + var testInstance = TestAssets.Get("AppWithToolDependency") + .CreateInstance(identifier: toolPrefersCLIRuntime ? "preferCLIRuntime" : "") + .WithSourceFiles() + .WithNuGetConfig(new RepoDirectoriesProvider().TestPackages); + + testInstance = testInstance.WithProjectChanges(project => + { + var ns = project.Root.Name.Namespace; + + var toolReference = project.Descendants(ns + "DotNetCliToolReference") + .Where(tr => tr.Attribute("Include").Value == "dotnet-portable") + .Single(); + + toolReference.Attribute("Include").Value = + toolPrefersCLIRuntime ? "dotnet-portable-v1-prefercli" : "dotnet-portable-v1"; + }); + + testInstance = testInstance.WithRestoreFiles(); + + new BuildCommand() + .WithProjectDirectory(testInstance.Root) + .Execute() + .Should().Pass(); + + new GenericCommand(toolPrefersCLIRuntime ? "portable-v1-prefercli" : "portable-v1") + .WithWorkingDirectory(testInstance.Root) + .Execute() + .Should().Fail(); + } + + [RequiresSpecificFrameworkTheory("netcoreapp1.1")] + [InlineData(true)] + [InlineData(false)] + public void IfPreviousVersionOfSharedFrameworkIsInstalled_ToolsTargetingItRun(bool toolPrefersCLIRuntime) + { + var testInstance = TestAssets.Get("AppWithToolDependency") + .CreateInstance(identifier: toolPrefersCLIRuntime ? "preferCLIRuntime" : "") + .WithSourceFiles() + .WithNuGetConfig(new RepoDirectoriesProvider().TestPackages); + + testInstance = testInstance.WithProjectChanges(project => + { + var ns = project.Root.Name.Namespace; + + var toolReference = project.Descendants(ns + "DotNetCliToolReference") + .Where(tr => tr.Attribute("Include").Value == "dotnet-portable") + .Single(); + + toolReference.Attribute("Include").Value = + toolPrefersCLIRuntime ? "dotnet-portable-v1-prefercli" : "dotnet-portable-v1"; + }); + + testInstance = testInstance.WithRestoreFiles(); + + new BuildCommand() + .WithProjectDirectory(testInstance.Root) + .Execute() + .Should().Pass(); + + var result = + new DotnetCommand(DotnetUnderTest.WithBackwardsCompatibleRuntimes) + .WithWorkingDirectory(testInstance.Root) + .Execute(toolPrefersCLIRuntime ? "portable-v1-prefercli" : "portable-v1"); + + result.Should().Pass() + .And.HaveStdOutContaining("I'm running on shared framework version 1.1.1!"); + + } + + [RequiresSpecificFrameworkFact("netcoreapp1.1")] + public void IfAToolHasNotBeenRestoredForNetCoreApp2_0ItFallsBackToNetCoreApp1_x() + { + string toolName = "dotnet-portable-v1"; + + var toolFolder = Path.Combine(new RepoDirectoriesProvider().NugetPackages, + ".tools", + toolName); + + // Other tests may have restored the tool for netcoreapp2.0, so delete its tools folder + if (Directory.Exists(toolFolder)) + { + Directory.Delete(toolFolder, true); + } + + var testInstance = TestAssets.Get("AppWithToolDependency") + .CreateInstance() + .WithSourceFiles() + .WithNuGetConfig(new RepoDirectoriesProvider().TestPackages); + + testInstance = testInstance.WithProjectChanges(project => + { + var ns = project.Root.Name.Namespace; + + // Remove reference to tool that won't restore on 1.x + project.Descendants(ns + "DotNetCliToolReference") + .Where(tr => tr.Attribute("Include").Value == "dotnet-PreferCliRuntime") + .Remove(); + + var toolReference = project.Descendants(ns + "DotNetCliToolReference") + .Where(tr => tr.Attribute("Include").Value == "dotnet-portable") + .Single(); + + toolReference.Attribute("Include").Value = toolName; + + // Restore tools for .NET Core 1.1 + project.Root.Element(ns + "PropertyGroup") + .Add(new XElement(ns + "DotnetCliToolTargetFramework", "netcoreapp1.1")); + + }); + + testInstance = testInstance.WithRestoreFiles(); + + var result = + new DotnetCommand(DotnetUnderTest.WithBackwardsCompatibleRuntimes) + .WithWorkingDirectory(testInstance.Root) + .Execute("portable-v1"); + + result.Should().Pass() + .And.HaveStdOutContaining("I'm running on shared framework version 1.1.1!"); + } + [Fact] public void CanInvokeToolWhosePackageNameIsDifferentFromDllName() { @@ -112,7 +239,7 @@ namespace Microsoft.DotNet.Tests .And.Pass(); } - [RequiresSpecificFrameworkFact("netcoreapp1.1")] // https://github.com/dotnet/cli/issues/6087 + [Fact] public void CanInvokeToolFromDirectDependenciesIfPackageNameDifferentFromToolName() { var testInstance = TestAssets.Get("AppWithDirectDepWithOutputName") @@ -242,7 +369,7 @@ namespace Microsoft.DotNet.Tests .Should().Fail(); } - [RequiresSpecificFrameworkFact("netcoreapp1.1")] // https://github.com/dotnet/cli/issues/6087 + [Fact] public void ToolsCanAccessDependencyContextProperly() { var testInstance = TestAssets.Get("DependencyContextFromTool") diff --git a/tools/Archiver/Archiver.csproj b/tools/Archiver/Archiver.csproj deleted file mode 100644 index 2a63e855f..000000000 --- a/tools/Archiver/Archiver.csproj +++ /dev/null @@ -1,22 +0,0 @@ - - - - - netcoreapp2.0 - Exe - $(CLI_SharedFrameworkVersion) - - - - - - - - - - - - - - - \ No newline at end of file