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/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/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/VSTestDesktopAndNetCore/VSTestDesktopAndNetCore.csproj b/TestAssets/TestProjects/VSTestDesktopAndNetCore/VSTestDesktopAndNetCore.csproj
index 84252d545..9cd7184f8 100644
--- a/TestAssets/TestProjects/VSTestDesktopAndNetCore/VSTestDesktopAndNetCore.csproj
+++ b/TestAssets/TestProjects/VSTestDesktopAndNetCore/VSTestDesktopAndNetCore.csproj
@@ -10,10 +10,6 @@
DESKTOP;$(DefineConstants)
-
- $(CLI_SharedFrameworkVersion)
-
-
diff --git a/TestAssets/TestProjects/VSTestDotNetCore/VSTestDotNetCore.csproj b/TestAssets/TestProjects/VSTestDotNetCore/VSTestDotNetCore.csproj
index 711143c68..0d07738af 100644
--- a/TestAssets/TestProjects/VSTestDotNetCore/VSTestDotNetCore.csproj
+++ b/TestAssets/TestProjects/VSTestDotNetCore/VSTestDotNetCore.csproj
@@ -4,7 +4,6 @@
Exe
netcoreapp2.0
- $(CLI_SharedFrameworkVersion)
diff --git a/TestAssets/TestProjects/VSTestXunitDotNetCore/VSTestXunitDotNetCore.csproj b/TestAssets/TestProjects/VSTestXunitDotNetCore/VSTestXunitDotNetCore.csproj
index ae4226e6c..d6016beea 100644
--- a/TestAssets/TestProjects/VSTestXunitDotNetCore/VSTestXunitDotNetCore.csproj
+++ b/TestAssets/TestProjects/VSTestXunitDotNetCore/VSTestXunitDotNetCore.csproj
@@ -4,7 +4,6 @@
Exe
netcoreapp2.0
- $(CLI_SharedFrameworkVersion)
diff --git a/build/DependencyVersions.props b/build/DependencyVersions.props
index d6500a942..99e55e6d9 100644
--- a/build/DependencyVersions.props
+++ b/build/DependencyVersions.props
@@ -4,7 +4,7 @@
2.0.0-preview1-002091-00
15.2.0-preview-000093-02
2.0.0-rc4-61325-08
- 2.0.0-alpha-20170425-6
+ 2.0.0-alpha-20170427-1
4.3.0-beta1-2418
1.0.0-rel-20170413-451
15.1.0-preview-20170414-04
diff --git a/build/test/TestPackageProjects.targets b/build/test/TestPackageProjects.targets
index 986fc569a..610d03937 100644
--- a/build/test/TestPackageProjects.targets
+++ b/build/test/TestPackageProjects.targets
@@ -136,6 +136,24 @@
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/run-build.ps1 b/run-build.ps1
index 12e7cb498..0c3ed5443 100644
--- a/run-build.ps1
+++ b/run-build.ps1
@@ -67,6 +67,9 @@ if (!(Test-Path $env:DOTNET_INSTALL_DIR))
# 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
diff --git a/run-build.sh b/run-build.sh
index 801a14bc1..16cece2d1 100755
--- a/run-build.sh
+++ b/run-build.sh
@@ -151,6 +151,10 @@ export VSTEST_BUILD_TRACE=1
export VSTEST_TRACE_BUILD=1
DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
+
+# Don't resolve shared frameworks from user or global locations
+DOTNET_MULTILEVEL_LOOKUP=0
+
toolsLocalPath="$REPOROOT/build_tools"
if [ ! -z $BOOTSTRAP_INSTALL_DIR]; then
toolsLocalPath = $BOOTSTRAP_INSTALL_DIR
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..7cd9a6113 100644
--- a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/ProjectToolsCommandResolver.cs
+++ b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/ProjectToolsCommandResolver.cs
@@ -170,10 +170,8 @@ namespace Microsoft.DotNet.Cli.Utils
toolLibraryRange,
toolPackageFramework,
toolLockFile,
- depsFileRoot);
-
- var packageFolders = toolLockFile.PackageFolders.Select(p =>
- PathUtility.EnsureNoTrailingDirectorySeparator(p.Path));
+ depsFileRoot,
+ project.ToolDepsJsonGeneratorProject);
Reporter.Verbose.WriteLine(string.Format(
LocalizableStrings.AttemptingToCreateCommandSpec,
@@ -184,7 +182,7 @@ namespace Microsoft.DotNet.Cli.Utils
commandName,
args,
_allowedCommandExtensions,
- packageFolders,
+ toolLockFile,
s_commandResolutionStrategy,
depsFilePath,
null);
@@ -281,7 +279,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 +291,7 @@ namespace Microsoft.DotNet.Cli.Utils
ProjectToolsCommandResolverName,
depsJsonPath));
- EnsureToolJsonDepsFileExists(toolLockFile, framework, depsJsonPath, toolLibrary);
+ EnsureToolJsonDepsFileExists(toolLockFile, framework, depsJsonPath, toolLibrary, toolDepsJsonGeneratorProject);
return depsJsonPath;
}
@@ -301,11 +300,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 +313,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/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/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/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.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.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-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.Tests/PackagedCommandTests.cs b/test/dotnet.Tests/PackagedCommandTests.cs
index e1816ca8f..bb75131d5 100644
--- a/test/dotnet.Tests/PackagedCommandTests.cs
+++ b/test/dotnet.Tests/PackagedCommandTests.cs
@@ -91,6 +91,80 @@ 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!");
+
+ }
+
[Fact]
public void CanInvokeToolWhosePackageNameIsDifferentFromDllName()
{
@@ -112,7 +186,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 +316,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")