Add workaround for tar warning about "file changed as we read it" in Docker under Windows host

This commit is contained in:
Daniel Plaisted 2018-11-08 08:10:33 -08:00
parent 5bfb634156
commit 853a27da6f
3 changed files with 24 additions and 1 deletions

View file

@ -29,6 +29,7 @@ if ($noninteractive)
docker run $interactiveFlag -t --rm --sig-proxy=true ` docker run $interactiveFlag -t --rm --sig-proxy=true `
--name "$dockerContainerName" ` --name "$dockerContainerName" `
-v "${RepoRoot}:/opt/code" ` -v "${RepoRoot}:/opt/code" `
-e DOTNET_CORESDK_IGNORE_TAR_EXIT_CODE=1 `
-e CHANNEL ` -e CHANNEL `
-e DOTNET_BUILD_SKIP_CROSSGEN ` -e DOTNET_BUILD_SKIP_CROSSGEN `
-e PUBLISH_TO_AZURE_BLOB ` -e PUBLISH_TO_AZURE_BLOB `

View file

@ -38,6 +38,20 @@ namespace Microsoft.DotNet.Build.Tasks
/// </summary> /// </summary>
public ITaskItem[] ExcludePatterns { get; set; } public ITaskItem[] ExcludePatterns { get; set; }
public bool IgnoreExitCode { get; set; }
protected override int ExecuteTool(string pathToTool, string responseFileCommands, string commandLineCommands)
{
int returnCode = base.ExecuteTool(pathToTool, responseFileCommands, commandLineCommands);
if (IgnoreExitCode)
{
returnCode = 0;
}
return returnCode;
}
protected override bool ValidateParameters() protected override bool ValidateParameters()
{ {
base.ValidateParameters(); base.ValidateParameters();

View file

@ -3,6 +3,13 @@
DependsOnTargets="GenerateLayout;GetCurrentRuntimeInformation" DependsOnTargets="GenerateLayout;GetCurrentRuntimeInformation"
AfterTargets="Build"> AfterTargets="Build">
<!-- When running in Docker under a Windows host, tar is warning "file changed as we read it" for several files and returning exit code 1.
So this flag allows that to be ignored. -->
<PropertyGroup Condition="'$(IgnoreTarExitCode)' == ''">
<IgnoreTarExitCode>false</IgnoreTarExitCode>
<IgnoreTarExitCode Condition="'$(DOTNET_CORESDK_IGNORE_TAR_EXIT_CODE)' == '1'">true</IgnoreTarExitCode>
</PropertyGroup>
<ZipFileCreateFromDirectory <ZipFileCreateFromDirectory
SourceDirectory="$(RedistLayoutPath)" SourceDirectory="$(RedistLayoutPath)"
DestinationArchive="$(ArtifactsShippingPackagesDir)$(ArtifactNameWithVersionSdk).zip" DestinationArchive="$(ArtifactsShippingPackagesDir)$(ArtifactNameWithVersionSdk).zip"
@ -12,7 +19,8 @@
Condition=" '$(OSName)' != 'win' " Condition=" '$(OSName)' != 'win' "
SourceDirectory="$(RedistLayoutPath)" SourceDirectory="$(RedistLayoutPath)"
DestinationArchive="$(ArtifactsShippingPackagesDir)$(ArtifactNameWithVersionSdk).tar.gz" DestinationArchive="$(ArtifactsShippingPackagesDir)$(ArtifactNameWithVersionSdk).tar.gz"
OverwriteDestination="true" /> OverwriteDestination="true"
IgnoreExitCode="$(IgnoreTarExitCode)"/>
</Target> </Target>
</Project> </Project>