Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

Commit

Permalink
Use a file list rather than globbing NETStandard assemblies
Browse files Browse the repository at this point in the history
This change minimizes the amount of work done during project evaluation by directly
setting the reference items to all the files/paths we know are part of the package.
  • Loading branch information
ericstj committed Sep 22, 2017
1 parent 981a2b5 commit adf5e3c
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 37 deletions.
33 changes: 19 additions & 14 deletions netstandard/pkg/NETStandard.Library.pkgproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@
<OmitDependencies>true</OmitDependencies>
<SkipValidatePackage>true</SkipValidatePackage>
<TargetsFileName>NETStandard.Library.targets</TargetsFileName>
<RootTargetsTemplate>targets\$(TargetsFileName)</RootTargetsTemplate>
<RootTargetsSource>$(IntermediateOutputPath)$(TargetsFileName)</RootTargetsSource>
<VersionTargetsTemplate>targets\netstandard\$(TargetsFileName)</VersionTargetsTemplate>
<NETStandardVersion>netstandard2.0</NETStandardVersion>
<VersionTargetsSource>$(IntermediateOutputPath)$(NETStandardVersion)\$(TargetsFileName)</VersionTargetsSource>
</PropertyGroup>

<Import Project="NETStandard.Library.dependencies.props" />

<ItemGroup>
<ProjectReference Include="..\ref\netstandard.csproj" />
<ProjectReference Include="shims\netstandard\dir.builds" />
<ProjectReference Include="shims\netfx\dir.builds" />

<File Include="$(RootTargetsSource)">
<TargetPath>build/$(Id).targets</TargetPath>
</File>

<File Include="targets\netstandard\$(TargetsFileName)">
<ProjectReference Include="shims\netstandard\dir.builds">
<Facade>true</Facade>
</ProjectReference>
<ProjectReference Include="shims\netfx\dir.builds">
<Facade>true</Facade>
</ProjectReference>

<File Include="$(VersionTargetsSource)">
<TargetPath>build/$(NETStandardVersion)/$(Id).targets</TargetPath>
</File>

Expand All @@ -34,11 +34,16 @@
</File>
</ItemGroup>

<Target Name="StampPackageVersionInTargets" BeforeTargets="GenerateNuSpec">
<MakeDir Directories="$(IntermediateOutputPath)" />
<Target Name="StampTargets" BeforeTargets="GenerateNuSpec">
<PropertyGroup>
<_FacadeFiles Condition="'%(File.Facade)' == 'true' AND '%(File.Extension)' == '.dll'" >@(File->'%24(MSBuildThisFileDirectory)\ref\%(FileName)%(Extension)')</_FacadeFiles>
</PropertyGroup>
<Error Condition="'$(_FacadeFiles)' == ''" Text="Could not determine facade file names to write to targets" />

<MakeDir Directories="$(IntermediateOutputPath)$(NETStandardVersion)" />

<WriteLinesToFile File="$(RootTargetsSource)"
Lines="$([System.IO.File]::ReadAllText('$(RootTargetsTemplate)').Replace('#VERSION#', '$(PackageVersion)'))"
<WriteLinesToFile File="$(VersionTargetsSource)"
Lines="$([System.IO.File]::ReadAllText('$(VersionTargetsTemplate)').Replace('#VERSION#', '$(PackageVersion)').Replace('#NETSTANDARDFACADES#', '$(_FacadeFiles)'))"
Overwrite="true" />
</Target>

Expand Down
17 changes: 0 additions & 17 deletions netstandard/pkg/targets/NETStandard.Library.targets

This file was deleted.

29 changes: 23 additions & 6 deletions netstandard/pkg/targets/netstandard/NETStandard.Library.targets
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<NETStandardLibraryPackageVersion>#VERSION#</NETStandardLibraryPackageVersion>
</PropertyGroup>

<!-- Only add references if we're actually targeting .NETStandard.
If the project is targeting some other TFM that is compatible with NETStandard we expect
that framework to provide all references for NETStandard, mscorlib, System.* in their own
targeting pack / SDK. -->
<PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETStandard'">
<_NetStandardLibraryRefPath>$(MSBuildThisFileDirectory)\ref\</_NetStandardLibraryRefPath>
</PropertyGroup>

<!-- import the TFM-agnostic targets -->
<Import Project="..\$(MSBuildThisFile)"/>
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETStandard'">
<Reference Include="$(MSBuildThisFileDirectory)\ref\netstandard.dll">
<!-- Private = false to make these reference only -->
<Private>false</Private>
<!-- hide these from Assemblies view in Solution Explorer, they will be shown under packages -->
<Visible>false</Visible>
<NuGetPackageId>NETStandard.Library</NuGetPackageId>
<NuGetPackageVersion>$(NETStandardLibraryPackageVersion)</NuGetPackageVersion>
</Reference>
<Reference Include="#NETSTANDARDFACADES#">
<Facade>true</Facade>
<!-- Private = false to make these reference only -->
<Private>false</Private>
<!-- hide these from Assemblies view in Solution Explorer, they will be shown under packages -->
<Visible>false</Visible>
<NuGetPackageId>NETStandard.Library</NuGetPackageId>
<NuGetPackageVersion>$(NETStandardLibraryPackageVersion)</NuGetPackageVersion>
</Reference>
</ItemGroup>
</Project>

0 comments on commit adf5e3c

Please sign in to comment.