Merge branch 'rel/1.0.0' into wrong_global_json_folders

This commit is contained in:
Livar 2017-02-01 15:53:10 -08:00 committed by GitHub
commit 408a0afe8e
4 changed files with 65 additions and 7 deletions

View file

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard1.5</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Something.Nonexistent" Version="1.1.1" />
</ItemGroup>
</Project>

View file

@ -41,10 +41,11 @@ namespace Microsoft.DotNet.Tools.MSBuild
{ {
Type loggerType = typeof(MSBuildLogger); Type loggerType = typeof(MSBuildLogger);
argsToForward = argsToForward.Concat(new[] argsToForward = argsToForward
{ .Concat(new[]
$"/Logger:{loggerType.FullName},{loggerType.GetTypeInfo().Assembly.Location}" {
}); $"/Logger:{loggerType.FullName},{loggerType.GetTypeInfo().Assembly.Location}"
});
} }
catch (Exception) catch (Exception)
{ {
@ -54,7 +55,7 @@ namespace Microsoft.DotNet.Tools.MSBuild
_forwardingApp = new ForwardingApp( _forwardingApp = new ForwardingApp(
GetMSBuildExePath(), GetMSBuildExePath(),
_msbuildRequiredParameters.Concat(argsToForward), _msbuildRequiredParameters.Concat(argsToForward.Select(Escape)),
environmentVariables: _msbuildRequiredEnvironmentVariables); environmentVariables: _msbuildRequiredEnvironmentVariables);
} }
@ -77,6 +78,13 @@ namespace Microsoft.DotNet.Tools.MSBuild
return app.Option("-v|--verbosity", LocalizableStrings.VerbosityOptionDescription, CommandOptionType.SingleValue); return app.Option("-v|--verbosity", LocalizableStrings.VerbosityOptionDescription, CommandOptionType.SingleValue);
} }
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() private static string GetMSBuildExePath()
{ {
return Path.Combine( return Path.Combine(

View file

@ -5,18 +5,27 @@ using System;
using System.Linq; using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Reflection; using System.Reflection;
using System.Runtime.InteropServices;
using FluentAssertions; using FluentAssertions;
using Microsoft.DotNet.Configurer; using Microsoft.DotNet.Configurer;
using Microsoft.DotNet.Tools.MSBuild; using Microsoft.DotNet.Tools.MSBuild;
using Microsoft.DotNet.Tools.Test.Utilities; using Microsoft.DotNet.Tools.Test.Utilities;
using NuGet.Protocol; using NuGet.Protocol;
using Xunit; using Xunit;
using Xunit.Abstractions;
using MSBuildCommand = Microsoft.DotNet.Tools.Test.Utilities.MSBuildCommand; using MSBuildCommand = Microsoft.DotNet.Tools.Test.Utilities.MSBuildCommand;
namespace Microsoft.DotNet.Cli.MSBuild.Tests namespace Microsoft.DotNet.Cli.MSBuild.Tests
{ {
public class GivenDotnetMSBuildBuildsProjects : TestBase public class GivenDotnetMSBuildBuildsProjects : TestBase
{ {
private readonly ITestOutputHelper _output;
public GivenDotnetMSBuildBuildsProjects(ITestOutputHelper output)
{
_output = output;
}
[Fact] [Fact]
public void ItRunsSpecifiedTargetsWithPropertiesCorrectly() public void ItRunsSpecifiedTargetsWithPropertiesCorrectly()
{ {
@ -76,6 +85,37 @@ namespace Microsoft.DotNet.Cli.MSBuild.Tests
} }
} }
[Fact]
public void WhenRestoreSourcesStartsWithUnixPathThenHttpsSourceIsParsedCorrectly()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return;
}
// this is a workaround for https://github.com/Microsoft/msbuild/issues/1622
var testInstance = TestAssets.Get("LibraryWithUnresolvablePackageReference")
.CreateInstance()
.WithSourceFiles();
var root = testInstance.Root;
var somePathThatExists = "/usr/local/bin";
var result = new DotnetCommand()
.WithWorkingDirectory(root)
.Execute($"msbuild /p:RestoreSources={somePathThatExists};https://api.nuget.org/v3/index.json /t:restore LibraryWithUnresolvablePackageReference.csproj");
_output.WriteLine($"[STDOUT]\n{result.StdOut}\n[STDERR]\n{result.StdErr}");
result.Should().Fail();
result.StdOut.Should()
.ContainVisuallySameFragment(
@"Feeds used:
/usr/local/bin
https://api.nuget.org/v3/index.json");
}
[Fact] [Fact]
public void WhenDotnetRunHelpIsInvokedAppArgumentsTextIsIncludedInOutput() public void WhenDotnetRunHelpIsInvokedAppArgumentsTextIsIncludedInOutput()
{ {
@ -85,7 +125,7 @@ namespace Microsoft.DotNet.Cli.MSBuild.Tests
var result = new TestCommand("dotnet") var result = new TestCommand("dotnet")
.WithWorkingDirectory(projectDirectory.Path) .WithWorkingDirectory(projectDirectory.Path)
.ExecuteWithCapturedOutput("run --help"); .ExecuteWithCapturedOutput("run --help");
result.ExitCode.Should().Be(0); result.ExitCode.Should().Be(0);
result.StdOut.Should().Contain(AppArgumentsText); result.StdOut.Should().Contain(AppArgumentsText);
} }

View file

@ -41,7 +41,6 @@ namespace Microsoft.DotNet.Tests
}; };
} }
} }
public static IEnumerable<object[]> LibraryDependencyToolArguments public static IEnumerable<object[]> LibraryDependencyToolArguments
{ {
get get