-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Use .NET SDK to generate deps.json for tools #6356
Use .NET SDK to generate deps.json for tools #6356
Conversation
2608da3
to
878037a
Compare
@eerhardt @nguerrera @livarcocc I think this is ready for review now. The corresponding SDK PR is dotnet/sdk#1128, which I still have a bit of work (tests, code review feedback) to do on. @natemcmaster FYI |
b9c3f93
to
6139036
Compare
@@ -0,0 +1,18 @@ | |||
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
CommandResolutionStrategy commandResolutionStrategy, | ||
string depsFilePath, | ||
string runtimeConfigPath); | ||
// Code review TODO: Is it OK to make breaking changes to the CLI Utils API surface? |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
else | ||
{ | ||
arguments.Add("--fx-version"); | ||
arguments.Add(new Muxer().SharedFxVersion); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
var toolTargetFramework = toolLockFile.Targets.First().TargetFramework.GetShortFolderName(); | ||
args.Add($"/p:TargetFramework={toolTargetFramework}"); | ||
|
||
|
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
||
if (result != 0) | ||
{ | ||
// TODO: Can / should we show the MSBuild output if there is a failure? |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
/// </summary> | ||
internal class ForwardingAppImplementation | ||
{ | ||
private const string s_hostExe = "dotnet"; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
private readonly IEnumerable<string> _argsToForward; | ||
private readonly string _depsFile; | ||
private readonly string _runtimeConfig; | ||
private readonly string _additionalProbingPath; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
/// <summary> | ||
/// A class which encapsulates logic needed to forward arguments from the current process to another process | ||
/// invoked with the dotnet.exe host. | ||
/// </summary> | ||
public class ForwardingApp |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -10,39 +10,25 @@ | |||
using Microsoft.DotNet.Cli; | |||
using Microsoft.DotNet.Cli.CommandLine; | |||
using System.Diagnostics; | |||
using Microsoft.DotNet.Cli.Utils; | |||
|
|||
namespace Microsoft.DotNet.Tools.MSBuild | |||
{ | |||
public class MSBuildForwardingApp |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
||
var coreAssembly = typeof(object).GetTypeInfo().Assembly; | ||
string coreFolder = Path.GetDirectoryName(coreAssembly.Location); | ||
string frameworkVersion = Path.GetFileName(coreFolder); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
||
namespace Microsoft.DotNet.Cli.Utils | ||
{ | ||
static class LockFileExtensions |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
{ | ||
// 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"); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
||
new GenericCommand(toolPrefersCLIRuntime ? "portable-v1-prefercli" : "portable-v1") | ||
.WithWorkingDirectory(testInstance.Root) | ||
.WithEnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0") |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
.Execute(toolPrefersCLIRuntime ? "portable-v1-prefercli" : "portable-v1"); | ||
|
||
result.Should().Pass() | ||
.And.HaveStdOutContaining("I'm running on shared framework version 1.1.1!"); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
var packageFolders = lockFile.GetNormalizedPackageFolders(); | ||
|
||
var packageFoldersCount = packageFolders.Count(); | ||
var userPackageFolder = packageFoldersCount == 1 ? string.Empty : packageFolders.First(); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -21,9 +21,41 @@ private static void AddAditionalParameters(string commandPath, IList<string> arg | |||
{ | |||
if(PrefersCliRuntime(commandPath)) | |||
{ | |||
arguments.Add("--fx-version"); | |||
arguments.Add(new Muxer().SharedFxVersion); | |||
var runtimeConfigFile = Path.ChangeExtension(commandPath, FileNameSuffixes.RuntimeConfigJson); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
||
public static string GetDataFromAppDomain(string propertyName) | ||
{ | ||
var appDomainType = typeof(object).GetTypeInfo().Assembly?.GetType("System.AppDomain"); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
…tead of doing so directly
…mework from test assets
… shared framework
For test assets, don't explicitly include the runtimeconfig file, as the pack command does it automatically
ba2a224
to
0c210b6
Compare
@dotnet-bot Test this please |
…ore 1.0 shared framework
@dotnet-bot test Linux x64 Release Build |
@dotnet-bot test Linux x64 Release |
@dotnet-bot test Ubuntu x64 Release Build |
@dotnet-bot test Linux x64 Release Build |
@dotnet-bot Test Linux x64 Release Build |
This PR calls into a project in the .NET SDK to create deps.json files for .NET CLI tools instead of doing so directly. This reduces logic duplication and will fix #6087.
The corresponding SDK PR is dotnet/sdk#1128. Once both PRs have gone through review, we'll merge the SDK PR, and then update this CLI PR to also insert the updated SDK. This PR doesn't yet include tests, but when it does they will fail in CI until the SDK is updated.