Skip to content

Commit

Permalink
Fix cannot publish self contain twice (#2467)
Browse files Browse the repository at this point in the history
  • Loading branch information
William Li authored Aug 10, 2018
1 parent adff69d commit a4e4645
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Tasks/Microsoft.NET.Build.Tasks/EmbedAppNameInHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@ protected override void ExecuteCore()
var destinationDirectory = Path.GetFullPath(AppHostDestinationDirectoryPath);
ModifiedAppHostPath = Path.Combine(destinationDirectory, $"{appbaseName}{hostExtension}");

AppHost.Create(
AppHostSourcePath,
ModifiedAppHostPath,
AppBinaryName);
if (!File.Exists(ModifiedAppHostPath))
{
AppHost.Create(
AppHostSourcePath,
ModifiedAppHostPath,
AppBinaryName);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,33 @@ public void It_errors_when_publishing_self_contained_without_apphost()
.And
.HaveStdOutContaining(Strings.CannotUseSelfContainedWithoutAppHost);
}

// repro https://github.com/dotnet/sdk/issues/2466
[Fact]
public void It_does_not_fail_publishing_a_self_twice()
{
var runtimeIdentifier = RuntimeEnvironment.GetRuntimeIdentifier();

var testAsset = _testAssetsManager
.CopyTestAsset(TestProjectName)
.WithSource();

var msbuidArgs = new string[] { "/p:SelfContained=true",
$"/p:TargetFramework={TargetFramework}",
$"/p:RuntimeIdentifier={runtimeIdentifier}"};

var restoreCommand = new RestoreCommand(Log, testAsset.TestRoot);

restoreCommand.Execute(msbuidArgs);

var publishCommand = new PublishCommand(Log, testAsset.TestRoot);
publishCommand
.Execute(msbuidArgs)
.Should().Pass();

publishCommand
.Execute(msbuidArgs)
.Should().Pass().And.NotHaveStdOutContaining("HelloWorld.exe' already exists");
}
}
}

0 comments on commit a4e4645

Please sign in to comment.