aspnetcore/build/FixPackageOutputDirs.targets

34 lines
1.4 KiB
XML

<Project>
<!--
The "Pack" target which emits .nupkg files to disk also holds a lock on those file
until the whole build process exits [1]. This makes it difficult to perform any
subsequent work on the package files, such as moving them or modifying their
contents. As a workaround, we cause the nupkgs to be written to a temporary
subdirectory, and then after they are emitted, our SubstituteProjectFileVariables
task writes its output to the original intended build directory.
[1] The file locking might be a bug in the NuGet client code. For example, see
https://github.com/NuGet/NuGet.Client/blob/63e8539791d4f662efffceb2185ad4510396d76e/src/NuGet.Core/NuGet.Commands/CommandRunners/PackCommandRunner.cs#L135
It opens a "PackageArchiveReader" (which in turn uses File.Open to open a file
handle) after creating each package, but never close/disposes it.
-->
<PropertyGroup>
<PackageDependsOn>RedirectPackageOutputDir;$(PackageDependsOn);RestorePackageOutputDir</PackageDependsOn>
</PropertyGroup>
<Target Name="RedirectPackageOutputDir">
<PropertyGroup>
<OrigBuildDir>$(BuildDir)</OrigBuildDir>
<BuildDir>$(BuildDir)unversioned\</BuildDir>
</PropertyGroup>
</Target>
<Target Name="RestorePackageOutputDir">
<PropertyGroup>
<BuildDir>$(OrigBuildDir)</BuildDir>
</PropertyGroup>
</Target>
</Project>