Generate deps for hosting startup in external dependencies

Use publish deps file instead of build deps file
This commit is contained in:
John Luo 2017-12-19 12:00:13 -08:00 committed by Nate McMaster
parent 867438a4ae
commit cabc9874c5
3 changed files with 19 additions and 4 deletions

View File

@ -176,7 +176,7 @@
<!--- MSBuild caches things if you run inproc so have to use Exec -->
<MSBuild Projects="$(HostingStartupWorkDir)HostingStartup.csproj"
Targets="Build;CollectDeps"
Targets="Publish;CollectDeps"
Properties="$(_HostingStartupProps)" />
</Target>
@ -185,7 +185,8 @@
<!-- Generate RS.Reference project -->
<RepoTasks.ResolveHostingStartupPackages
BuildArtifacts="@(ArtifactInfo)"
PackageArtifacts="@(PackageArtifact)">
PackageArtifacts="@(PackageArtifact)"
ExternalDependencies="@(ExternalDependency)">
<Output TaskParameter="HostingStartupArtifacts" ItemName="HostingStartupArtifacts" />
</RepoTasks.ResolveHostingStartupPackages>

View File

@ -15,6 +15,9 @@ namespace RepoTasks
[Required]
public ITaskItem[] PackageArtifacts { get; set; }
[Required]
public ITaskItem[] ExternalDependencies { get; set; }
[Output]
public ITaskItem[] HostingStartupArtifacts { get; set; }
@ -22,7 +25,18 @@ namespace RepoTasks
{
// Parse input
var hostingStartupArtifacts = PackageArtifacts.Where(p => p.GetMetadata("HostingStartup") == "true");
HostingStartupArtifacts = BuildArtifacts.Where(p => hostingStartupArtifacts.Any(h => h.GetMetadata("Identity") == p.GetMetadata("PackageId"))).ToArray();
var externalHostingStartupArtifacts = ExternalDependencies.Where(p => p.GetMetadata("HostingStartup") == "true");
var hostingStartups = BuildArtifacts.Where(p => hostingStartupArtifacts.Any(h => h.GetMetadata("Identity") == p.GetMetadata("PackageId")));
foreach (var externalHostingStartup in externalHostingStartupArtifacts)
{
// The parameters PackageId and Version are required for output. For external dependencies, the identity is the pacakge id.
externalHostingStartup.SetMetadata("PackageId", externalHostingStartup.GetMetadata("Identity"));
hostingStartups = hostingStartups.Append(externalHostingStartup);
}
HostingStartupArtifacts = hostingStartups.ToArray();
return true;
}

View File

@ -26,6 +26,6 @@
<DestinationDepsFile>$(DepsOutputPath)\$(HostingStartupPackageName)\shared\Microsoft.NETCore.App\$(DepsRuntimeFrameworkVersion)\$(HostingStartupPackageName).deps.json</DestinationDepsFile>
</PropertyGroup>
<Copy SourceFiles="$(ProjectDepsFilePath)" DestinationFiles="$(DestinationDepsFile)" />
<Copy SourceFiles="$(PublishDepsFilePath)" DestinationFiles="$(DestinationDepsFile)" />
</Target>
</Project>