Add selective unzipping to avoid ASP.NET clobbering NetCore.App (#15272)
This commit is contained in:
commit
59530fd164
2 changed files with 39 additions and 7 deletions
|
@ -32,6 +32,11 @@ namespace Microsoft.DotNet.Build.Tasks
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool CleanDestination { get; set; }
|
public bool CleanDestination { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A list of directories, semicolon deliminated, relative to the root of the archive to include. If empty all directories will be copied.
|
||||||
|
/// </summary>
|
||||||
|
public ITaskItem[] DirectoriesToCopy { get; set; }
|
||||||
|
|
||||||
protected override bool ValidateParameters()
|
protected override bool ValidateParameters()
|
||||||
{
|
{
|
||||||
base.ValidateParameters();
|
base.ValidateParameters();
|
||||||
|
@ -73,13 +78,37 @@ namespace Microsoft.DotNet.Build.Tasks
|
||||||
{
|
{
|
||||||
if (ValidateParameters())
|
if (ValidateParameters())
|
||||||
{
|
{
|
||||||
#if NETFRAMEWORK
|
if (DirectoriesToCopy != null && DirectoriesToCopy.Length != 0)
|
||||||
// .NET Framework doesn't have overload to overwrite files
|
{
|
||||||
ZipFile.ExtractToDirectory(SourceArchive, DestinationDirectory);
|
var zip = new ZipArchive(File.OpenRead(SourceArchive));
|
||||||
#else
|
string loc = DestinationDirectory;
|
||||||
ZipFile.ExtractToDirectory(SourceArchive, DestinationDirectory, overwriteFiles: true);
|
foreach (var entry in zip.Entries)
|
||||||
#endif
|
{
|
||||||
|
foreach (var directory in DirectoriesToCopy)
|
||||||
|
{
|
||||||
|
if (entry.FullName.StartsWith(directory.ItemSpec))
|
||||||
|
{
|
||||||
|
if (!Directory.Exists(Path.Combine(DestinationDirectory, Path.GetDirectoryName(entry.FullName))))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(Path.Combine(DestinationDirectory, Path.GetDirectoryName(entry.FullName)));
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.LogMessage(Path.GetDirectoryName(entry.FullName));
|
||||||
|
entry.ExtractToFile(Path.Combine(loc, entry.FullName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#if NETFRAMEWORK
|
||||||
|
// .NET Framework doesn't have overload to overwrite files
|
||||||
|
ZipFile.ExtractToDirectory(SourceArchive, DestinationDirectory);
|
||||||
|
#else
|
||||||
|
|
||||||
|
ZipFile.ExtractToDirectory(SourceArchive, DestinationDirectory, overwriteFiles: true);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -274,6 +274,7 @@
|
||||||
<BaseUrl Condition=" '$(DotNetBuildFromSource)' == 'true' AND '$(DotNetBuildFromSourceFlavor)' == 'Product' ">$(AspNetCoreSharedFxRootUrl)</BaseUrl>
|
<BaseUrl Condition=" '$(DotNetBuildFromSource)' == 'true' AND '$(DotNetBuildFromSourceFlavor)' == 'Product' ">$(AspNetCoreSharedFxRootUrl)</BaseUrl>
|
||||||
<DownloadFileName>$(AspNetCoreSharedFxArchiveFileName)</DownloadFileName>
|
<DownloadFileName>$(AspNetCoreSharedFxArchiveFileName)</DownloadFileName>
|
||||||
<RelativeLayoutPath></RelativeLayoutPath>
|
<RelativeLayoutPath></RelativeLayoutPath>
|
||||||
|
<DirectoriesToCopy>shared/Microsoft.AspNetCore.App</DirectoriesToCopy>
|
||||||
</BundledLayoutComponent>
|
</BundledLayoutComponent>
|
||||||
|
|
||||||
<!-- The AspNet does not provide native MacOS PKG installers at this time; we use AspNet archives.
|
<!-- The AspNet does not provide native MacOS PKG installers at this time; we use AspNet archives.
|
||||||
|
@ -334,6 +335,7 @@
|
||||||
<BundledLayoutComponent Include="WinFormsAndWpfSharedFxArchiveFile">
|
<BundledLayoutComponent Include="WinFormsAndWpfSharedFxArchiveFile">
|
||||||
<BaseUrl>$(WinFormsAndWpfSharedFxRootUrl)$(WindowsDesktopBlobVersion)</BaseUrl>
|
<BaseUrl>$(WinFormsAndWpfSharedFxRootUrl)$(WindowsDesktopBlobVersion)</BaseUrl>
|
||||||
<DownloadFileName>$(WinFormsAndWpfSharedFxArchiveFileName)</DownloadFileName>
|
<DownloadFileName>$(WinFormsAndWpfSharedFxArchiveFileName)</DownloadFileName>
|
||||||
|
<DirectoriesToCopy>shared/Microsoft.WindowsDesktop.App</DirectoriesToCopy>
|
||||||
</BundledLayoutComponent>
|
</BundledLayoutComponent>
|
||||||
|
|
||||||
<BundledInstallerComponent Include="DownloadedWinFormsAndWpfSharedFrameworkInstallerFile"
|
<BundledInstallerComponent Include="DownloadedWinFormsAndWpfSharedFrameworkInstallerFile"
|
||||||
|
@ -447,7 +449,8 @@
|
||||||
|
|
||||||
<Target Name="LayoutBundledComponents">
|
<Target Name="LayoutBundledComponents">
|
||||||
<ExtractArchiveToDirectory SourceArchive="%(BundledLayoutComponent.DownloadDestination)"
|
<ExtractArchiveToDirectory SourceArchive="%(BundledLayoutComponent.DownloadDestination)"
|
||||||
DestinationDirectory="$(RedistLayoutPath)/%(BundledLayoutComponent.RelativeLayoutPath)" />
|
DestinationDirectory="$(RedistLayoutPath)/%(BundledLayoutComponent.RelativeLayoutPath)"
|
||||||
|
DirectoriesToCopy="%(BundledLayoutComponent.DirectoriesToCopy)"/>
|
||||||
|
|
||||||
<Copy SourceFiles="@(BundledLayoutPackageDownloadFilesWithDestination)"
|
<Copy SourceFiles="@(BundledLayoutPackageDownloadFilesWithDestination)"
|
||||||
DestinationFiles="@(BundledLayoutPackageDownloadFilesWithDestination->'%(DestinationPath)')"
|
DestinationFiles="@(BundledLayoutPackageDownloadFilesWithDestination->'%(DestinationPath)')"
|
||||||
|
|
Loading…
Reference in a new issue