diff --git a/src/dotnet/commands/dotnet-pack/PackCommandParser.cs b/src/dotnet/commands/dotnet-pack/PackCommandParser.cs index 036e120725..0de1123a53 100644 --- a/src/dotnet/commands/dotnet-pack/PackCommandParser.cs +++ b/src/dotnet/commands/dotnet-pack/PackCommandParser.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Generic; +using System.IO; using System.Linq; using Microsoft.DotNet.Cli.CommandLine; using Microsoft.DotNet.Tools; @@ -22,7 +23,7 @@ public static Command Pack() => LocalizableStrings.CmdOutputDirDescription, Accept.ExactlyOneArgument() .With(name: LocalizableStrings.CmdOutputDir) - .ForwardAsSingle(o => $"/p:PackageOutputPath={o.Arguments.Single()}")), + .ForwardAsSingle(o => $"/p:PackageOutputPath={Path.GetFullPath(o.Arguments.Single())}")), Create.Option( "--no-build", LocalizableStrings.CmdNoBuildOptionDescription, diff --git a/src/dotnet/commands/dotnet-publish/PublishCommandParser.cs b/src/dotnet/commands/dotnet-publish/PublishCommandParser.cs index 9149c1dfdc..93548d2bda 100644 --- a/src/dotnet/commands/dotnet-publish/PublishCommandParser.cs +++ b/src/dotnet/commands/dotnet-publish/PublishCommandParser.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Generic; +using System.IO; using System.Linq; using Microsoft.DotNet.Cli.CommandLine; using Microsoft.DotNet.Tools; @@ -22,7 +23,7 @@ public static Command Publish() => LocalizableStrings.OutputOptionDescription, Accept.ExactlyOneArgument() .With(name: LocalizableStrings.OutputOption) - .ForwardAsSingle(o => $"/p:PublishDir={o.Arguments.Single()}")), + .ForwardAsSingle(o => $"/p:PublishDir={Path.GetFullPath(o.Arguments.Single())}")), CommonOptions.FrameworkOption(), CommonOptions.RuntimeOption(), CommonOptions.ConfigurationOption(), diff --git a/test/dotnet-msbuild.Tests/GivenDotnetPackInvocation.cs b/test/dotnet-msbuild.Tests/GivenDotnetPackInvocation.cs index aba1b15a68..9a2738ab68 100644 --- a/test/dotnet-msbuild.Tests/GivenDotnetPackInvocation.cs +++ b/test/dotnet-msbuild.Tests/GivenDotnetPackInvocation.cs @@ -5,6 +5,7 @@ using FluentAssertions; using Xunit; using System; +using System.IO; using System.Linq; namespace Microsoft.DotNet.Cli.MSBuild.Tests @@ -15,8 +16,8 @@ public class GivenDotnetPackInvocation [Theory] [InlineData(new string[] { }, "")] - [InlineData(new string[] { "-o", "" }, "/p:PackageOutputPath=")] - [InlineData(new string[] { "--output", "" }, "/p:PackageOutputPath=")] + [InlineData(new string[] { "-o", "TestPackageOutputPath" }, "/p:PackageOutputPath=TestPackageOutputPath")] + [InlineData(new string[] { "--output", "TestPackageOutputPath" }, "/p:PackageOutputPath=TestPackageOutputPath")] [InlineData(new string[] { "--no-build" }, "/p:NoBuild=true")] [InlineData(new string[] { "--include-symbols" }, "/p:IncludeSymbols=true")] [InlineData(new string[] { "--include-source" }, "/p:IncludeSource=true")] @@ -31,6 +32,7 @@ public class GivenDotnetPackInvocation public void MsbuildInvocationIsCorrect(string[] args, string expectedAdditionalArgs) { expectedAdditionalArgs = (string.IsNullOrEmpty(expectedAdditionalArgs) ? "" : $" {expectedAdditionalArgs}"); + expectedAdditionalArgs = expectedAdditionalArgs.Replace("", Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar); var msbuildPath = ""; PackCommand.FromArgs(args, msbuildPath) diff --git a/test/dotnet-msbuild.Tests/GivenDotnetPublishInvocation.cs b/test/dotnet-msbuild.Tests/GivenDotnetPublishInvocation.cs index f7cf3838dc..633b859ba3 100644 --- a/test/dotnet-msbuild.Tests/GivenDotnetPublishInvocation.cs +++ b/test/dotnet-msbuild.Tests/GivenDotnetPublishInvocation.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; +using System.IO; using FluentAssertions; using System.Linq; using Microsoft.DotNet.Cli.CommandLine; @@ -28,8 +29,8 @@ public GivenDotnetPublishInvocation(ITestOutputHelper output) [InlineData(new string[] { "--framework", "" }, "/p:TargetFramework=")] [InlineData(new string[] { "-r", "" }, "/p:RuntimeIdentifier=")] [InlineData(new string[] { "--runtime", "" }, "/p:RuntimeIdentifier=")] - [InlineData(new string[] { "-o", "" }, "/p:PublishDir=")] - [InlineData(new string[] { "--output", "" }, "/p:PublishDir=")] + [InlineData(new string[] { "-o", "TestPublishDir" }, "/p:PublishDir=TestPublishDir")] + [InlineData(new string[] { "--output", "TestPublishDir" }, "/p:PublishDir=TestPublishDir")] [InlineData(new string[] { "-c", "" }, "/p:Configuration=")] [InlineData(new string[] { "--configuration", "" }, "/p:Configuration=")] [InlineData(new string[] { "--version-suffix", "" }, "/p:VersionSuffix=")] @@ -41,6 +42,7 @@ public GivenDotnetPublishInvocation(ITestOutputHelper output) public void MsbuildInvocationIsCorrect(string[] args, string expectedAdditionalArgs) { expectedAdditionalArgs = (string.IsNullOrEmpty(expectedAdditionalArgs) ? "" : $" {expectedAdditionalArgs}"); + expectedAdditionalArgs = expectedAdditionalArgs.Replace("", Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar); var msbuildPath = ""; PublishCommand.FromArgs(args, msbuildPath) @@ -55,8 +57,8 @@ public void MsbuildInvocationIsCorrect(string[] args, string expectedAdditionalA [InlineData(new string[] { "--framework", "" }, "/p:TargetFramework=")] [InlineData(new string[] { "-r", "" }, "/p:RuntimeIdentifier=")] [InlineData(new string[] { "--runtime", "" }, "/p:RuntimeIdentifier=")] - [InlineData(new string[] { "-o", "" }, "/p:PublishDir=")] - [InlineData(new string[] { "--output", "" }, "/p:PublishDir=")] + [InlineData(new string[] { "-o", "TestPublishDir" }, "/p:PublishDir=TestPublishDir")] + [InlineData(new string[] { "--output", "TestPublishDir" }, "/p:PublishDir=TestPublishDir")] [InlineData(new string[] { "-c", "" }, "/p:Configuration=")] [InlineData(new string[] { "--configuration", "" }, "/p:Configuration=")] [InlineData(new string[] { "--version-suffix", "" }, "/p:VersionSuffix=")] @@ -65,6 +67,8 @@ public void MsbuildInvocationIsCorrect(string[] args, string expectedAdditionalA [InlineData(new string[] { "--verbosity", "minimal" }, "/verbosity:minimal")] public void OptionForwardingIsCorrect(string[] args, string expectedAdditionalArgs) { + expectedAdditionalArgs = expectedAdditionalArgs.Replace("", Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar); + var expectedArgs = expectedAdditionalArgs.Split(' ', StringSplitOptions.RemoveEmptyEntries); var parser = Parser.Instance;