Skip to content
This repository has been archived by the owner on Apr 20, 2023. It is now read-only.

Use .NET SDK to generate deps.json for tools #6356

Merged
merged 18 commits into from
Apr 28, 2017

Conversation

dsplaisted
Copy link
Member

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.

@dsplaisted
Copy link
Member Author

@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

@@ -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.

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.

else
{
arguments.Add("--fx-version");
arguments.Add(new Muxer().SharedFxVersion);

This comment was marked as spam.

var toolTargetFramework = toolLockFile.Targets.First().TargetFramework.GetShortFolderName();
args.Add($"/p:TargetFramework={toolTargetFramework}");


This comment was marked as spam.


if (result != 0)
{
// TODO: Can / should we show the MSBuild output if there is a failure?

This comment was marked as spam.

/// </summary>
internal class ForwardingAppImplementation
{
private const string s_hostExe = "dotnet";

This comment was marked as spam.

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.

/// <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.

@@ -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.


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.

@eerhardt
Copy link
Member

using Microsoft.DotNet.Tools.Common;

Copyright. on all new files.


Refers to: src/Microsoft.DotNet.Cli.Utils/Extensions/LockFileExtensions.cs:1 in 6139036. [](commit_id = 6139036, deletion_comment = False)


namespace Microsoft.DotNet.Cli.Utils
{
static class LockFileExtensions

This comment was marked as spam.

{
// 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.


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.

.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.

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.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@@ -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.

This comment was marked as spam.

This comment was marked as spam.


public static string GetDataFromAppDomain(string propertyName)
{
var appDomainType = typeof(object).GetTypeInfo().Assembly?.GetType("System.AppDomain");

This comment was marked as spam.

@livarcocc
Copy link

@dotnet-bot Test this please

@dsplaisted
Copy link
Member Author

@dotnet-bot test Linux x64 Release Build

@dsplaisted
Copy link
Member Author

@dotnet-bot test Linux x64 Release

@dsplaisted
Copy link
Member Author

@dotnet-bot test Ubuntu x64 Release Build

@livarcocc
Copy link

livarcocc commented Apr 27, 2017

@dotnet-bot test Linux x64 Release Build

@livarcocc
Copy link

@dotnet-bot Test Linux x64 Release Build

@livarcocc livarcocc merged commit 6cb2eb0 into dotnet:release/2.0.0 Apr 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants