Skip to content

Fix dotnet store for netcoreapp3.0 #3345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/Tasks/Microsoft.NET.Build.Tasks/GetPackageDirectory.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
Expand All @@ -16,17 +17,26 @@ public class GetPackageDirectory : TaskBase

public string[] PackageFolders { get; set; } = Array.Empty<string>();

public string AssetsFileWithAdditionalPackageFolders { get; set; }

[Output]
public ITaskItem[] Output { get; set; }

protected override void ExecuteCore()
{
if (Items.Length == 0 || PackageFolders.Length == 0)
if (Items.Length == 0 || (PackageFolders.Length == 0 && string.IsNullOrEmpty(AssetsFileWithAdditionalPackageFolders)))
{
Output = Items;
return;
}

if (!string.IsNullOrEmpty(AssetsFileWithAdditionalPackageFolders))
{
var lockFileCache = new LockFileCache(this);
var lockFile = lockFileCache.GetLockFile(AssetsFileWithAdditionalPackageFolders);
PackageFolders = PackageFolders.Concat(lockFile.PackageFolders.Select(p => p.Path)).ToArray();
}

var packageResolver = NuGetPackageResolver.CreateResolver(PackageFolders);

int index = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ Copyright (c) .NET Foundation. All rights reserved.
SkipUnchangedFiles=$(SkipUnchangedFiles);
PreserveStoreLayout=$(PreserveStoreLayout);
CreateProfilingSymbols=$(CreateProfilingSymbols);
StoreSymbolsStagingDir=$(StoreSymbolsStagingDir)"
ContinueOnError="WarnAndContinue">
StoreSymbolsStagingDir=$(StoreSymbolsStagingDir)">
<Output ItemName="AllResolvedPackagesPublished" TaskParameter="TargetOutputs" />
</MSBuild>
</Target>
Expand All @@ -71,6 +70,8 @@ Copyright (c) .NET Foundation. All rights reserved.

<ItemGroup>
<PackageReferencesToStore Include="$(MSBuildProjectFullPath)">
<PackageName>%(PackageReference.Identity)</PackageName>
<PackageVersion>%(PackageReference.Version)</PackageVersion>
<AdditionalProperties>
StorePackageName=%(PackageReference.Identity);
StorePackageVersion=%(PackageReference.Version);
Expand All @@ -93,17 +94,15 @@ Copyright (c) .NET Foundation. All rights reserved.
<!-- Restore phase -->
<MSBuild Projects="@(PackageReferencesToStore)"
Targets="RestoreForComposeStore"
BuildInParallel="$(BuildInParallel)"
ContinueOnError="WarnAndContinue">
BuildInParallel="$(BuildInParallel)">
</MSBuild>


<!-- Resolve phase-->
<MSBuild Projects="@(PackageReferencesToStore)"
Targets="StoreResolver"
Properties="MSBuildProjectExtensionsPath=$(ComposeWorkingDir)\%(PackageReference.Identity)_$([System.String]::Copy('%(PackageReference.Version)').Replace('*','-'))\;"
BuildInParallel="$(BuildInParallel)"
ContinueOnError="WarnAndContinue">
Properties="SelfContained=false;MSBuildProjectExtensionsPath=$(ComposeWorkingDir)\%(PackageReferencesToStore.PackageName)_$([System.String]::Copy('%(PackageReferencesToStore.PackageVersion)').Replace('*','-'))\;"
BuildInParallel="$(BuildInParallel)">
<Output ItemName="ResolvedPackagesFromMapper" TaskParameter="TargetOutputs" />
</MSBuild>
</Target>
Expand Down Expand Up @@ -157,8 +156,7 @@ Copyright (c) .NET Foundation. All rights reserved.
Importance="high"/>
<RemoveDir
Condition="'$(PreserveComposeWorkingDir)' != 'true'"
Directories="$(ComposeWorkingDir)"
ContinueOnError="WarnAndContinue"/>
Directories="$(ComposeWorkingDir)" />
</Target>

<!--
Expand All @@ -177,7 +175,7 @@ Copyright (c) .NET Foundation. All rights reserved.
</ItemGroup>

<Copy SourceFiles = "@(_OptimizedResolvedFileToPublish)"
DestinationFolder="$(PublishDir)%(RecursiveDir)"
DestinationFolder="$(PublishDir)%(_OptimizedResolvedFileToPublish.RecursiveDir)"
OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
Retries="$(CopyRetryCount)"
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
Expand All @@ -189,7 +187,7 @@ Copyright (c) .NET Foundation. All rights reserved.
</Copy>

<Copy SourceFiles="@(_OptimizedSymbolFileToPublish)"
DestinationFolder="$(ProfilingSymbolsDir)%(RecursiveDir)"
DestinationFolder="$(ProfilingSymbolsDir)%(_OptimizedSymbolFileToPublish.RecursiveDir)"
OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
Retries="$(CopyRetryCount)"
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ Copyright (c) .NET Foundation. All rights reserved.
CrossgenExe=$(Crossgen);
CrossgenJit=$(JitPath);
CrossgenInputAssembly=%(_ManagedResolvedFilesToOptimize.Fullpath);
CrossgenOutputAssembly=$(_RuntimeOptimizedDir)$(DirectorySeparatorChar)%(FileName)%(Extension);
CrossgenSubOutputPath=%(DestinationSubPath);
CrossgenOutputAssembly=$(_RuntimeOptimizedDir)$(DirectorySeparatorChar)%(_ManagedResolvedFilesToOptimize.FileName)%(_ManagedResolvedFilesToOptimize.Extension);
CrossgenSubOutputPath=%(_ManagedResolvedFilesToOptimize.DestinationSubPath);
_RuntimeOptimizedDir=$(_RuntimeOptimizedDir);
PublishDir=$(StoreStagingDir);
CrossgenPlatformAssembliesPath=$(_RuntimeRefDir)$(PathSeparator)$(_NetCoreRefDir);
Expand Down Expand Up @@ -147,7 +147,8 @@ Copyright (c) .NET Foundation. All rights reserved.
<!--Optimization skip if the assembly is already present in the final output directory-->
<Exec
Command="$(CrossgenCommandline)"
Condition="!Exists($([System.IO.Path]::Combine($(PublishDir),$(CrossgenSubOutputPath))))" />
Condition="!Exists($([System.IO.Path]::Combine($(PublishDir),$(CrossgenSubOutputPath))))"
IgnoreStandardErrorWarningFormat="true" />

<Copy SourceFiles = "$(CrossgenOutputAssembly)"
DestinationFiles="$(PublishDir)\$(CrossgenSubOutputPath)"
Expand All @@ -163,7 +164,8 @@ Copyright (c) .NET Foundation. All rights reserved.
<MakeDir Directories="$(CrossgenProfilingSymbolsOutputDirectory)"
Condition="'$(CreateProfilingSymbols)' == 'true' and Exists($(CrossgenOutputAssembly))" />
<Exec Command="$(CrossgenExe) -nologo -readytorun -platform_assemblies_paths $(CrossgenPlatformAssembliesPath) -$(CreateProfilingSymbolsOptionName) $(CrossgenProfilingSymbolsOutputDirectory) $(CrossgenOutputAssembly)"
Condition="'$(CreateProfilingSymbols)' == 'true' and Exists($(CrossgenOutputAssembly))" />
Condition="'$(CreateProfilingSymbols)' == 'true' and Exists($(CrossgenOutputAssembly))"
IgnoreStandardErrorWarningFormat="true" />

<ItemGroup>
<_ProfilingSymbols Include="$(CrossgenProfilingSymbolsOutputDirectory)\*"
Expand Down Expand Up @@ -267,12 +269,12 @@ Copyright (c) .NET Foundation. All rights reserved.
<MSBuild Projects="$(MSBuildProjectFullPath)"
Targets="Restore"
Properties="RestoreGraphProjectInput=$(MSBuildProjectFullPath);
DisableImplicitFrameworkReferences=true;
RestoreOutputPath=$(_CrossProjFileDir);
StorePackageName=$(MicrosoftNETPlatformLibrary);
StorePackageVersion=%(PackageReferenceForCrossGen.Version);"/>

<ResolveCopyLocalAssets AssetsFilePath="$(_CrossProjAssetsFile)"
<ResolveCopyLocalAssets Condition="'$(_TargetFrameworkVersionWithoutV)' &lt; '3.0'"
AssetsFilePath="$(_CrossProjAssetsFile)"
TargetFramework="$(_TFM)"
RuntimeIdentifier="$(RuntimeIdentifier)"
PlatformLibraryName="$(MicrosoftNETPlatformLibrary)"
Expand All @@ -284,6 +286,18 @@ Copyright (c) .NET Foundation. All rights reserved.
<Output TaskParameter="ResolvedAssets" ItemName="CrossgenResolvedAssembliesToPublish" />
</ResolveCopyLocalAssets>

<GetPackageDirectory Condition="'$(_TargetFrameworkVersionWithoutV)' >= '3.0'"
Items="@(RuntimePack)"
AssetsFileWithAdditionalPackageFolders="$(_CrossProjAssetsFile)">
<Output TaskParameter="Output" ItemName="_CrossgenRuntimePack" />
</GetPackageDirectory>

<ResolveRuntimePackAssets Condition="'$(_TargetFrameworkVersionWithoutV)' >= '3.0'"
FrameworkReferences="@(FrameworkReference)"
ResolvedRuntimePacks="@(_CrossgenRuntimePack)">
<Output TaskParameter="RuntimePackAssets" ItemName="CrossgenResolvedAssembliesToPublish" />
</ResolveRuntimePackAssets>

<!-- Copy managed files to a flat temp directory for passing it as ref for crossgen -->
<Copy SourceFiles = "@(CrossgenResolvedAssembliesToPublish)"
DestinationFolder="$(_NetCoreRefDir)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public void store_nativeonlyassets()
storeDirectory.Should().OnlyHaveFiles(files_on_disk);
}

[CoreMSBuildOnlyFact(Skip = "https://github.com/dotnet/sdk/issues/2914")]
[CoreMSBuildOnlyFact]
public void compose_multifile()
{
TestAsset simpleDependenciesAsset = _testAssetsManager
Expand All @@ -177,7 +177,7 @@ public void compose_multifile()
var additionalproj2 = Path.Combine(simpleDependenciesAsset.TestRoot, "FluentAssertion.xml");

storeCommand
.Execute("/bl:store.binlog", $"/p:RuntimeIdentifier={_runtimeRid}", $"/p:TargetFramework={_tfm}", $"/p:Additionalprojects={additionalproj1}%3b{additionalproj2}", $"/p:ComposeDir={OutputFolder}", $"/p:ComposeWorkingDir={WorkingDir}", "/p:DoNotDecorateComposeDir=true", "/p:CreateProfilingSymbols=false")
.Execute($"/p:RuntimeIdentifier={_runtimeRid}", $"/p:TargetFramework={_tfm}", $"/p:Additionalprojects={additionalproj1}%3b{additionalproj2}", $"/p:ComposeDir={OutputFolder}", $"/p:ComposeWorkingDir={WorkingDir}", "/p:DoNotDecorateComposeDir=true", "/p:CreateProfilingSymbols=false")
.Should()
.Pass();
DirectoryInfo storeDirectory = new DirectoryInfo(OutputFolder);
Expand Down Expand Up @@ -213,7 +213,7 @@ public void compose_multifile()

foreach (var pkg in knownpackage)
{
packagescomposed.Should().Contain(elem => elem.Equals(pkg), "package {0}, version {1} was not expected to be stored", pkg.Id, pkg.Version);
packagescomposed.Should().Contain(elem => elem.Equals(pkg), "package {0}, version {1} was expected to be stored", pkg.Id, pkg.Version);
}
}

Expand Down Expand Up @@ -300,7 +300,7 @@ public void It_creates_profiling_symbols()
}
}

[CoreMSBuildOnlyFact(Skip = "https://github.com/dotnet/sdk/issues/2914")]
[CoreMSBuildOnlyFact]
public void It_stores_when_targeting_netcoreapp3()
{
const string TFM = "netcoreapp3.0";
Expand Down