-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from onovotny/reference-assms
Reference assms
- Loading branch information
Showing
10 changed files
with
209 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
140 changes: 140 additions & 0 deletions
140
Source/MSBuild.Sdk.Extras/Build/ReferenceAssembly.targets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
|
||
<PropertyGroup> | ||
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<!-- Default is not a reference assembly --> | ||
<ExtrasIsReferenceAssembly Condition="'$(ExtrasIsReferenceAssembly)' == ''">false</ExtrasIsReferenceAssembly> | ||
</PropertyGroup> | ||
|
||
|
||
<PropertyGroup Condition="'$(ExtrasIsReferenceAssembly)' == 'true'"> | ||
<DefineConstants Condition=" '$(_SdkLanguageSourceName)' != 'VisualBasic' ">$(DefineConstants);REFERENCE_ASSEMBLY</DefineConstants> | ||
<DefineConstants Condition=" '$(_SdkLanguageSourceName)' == 'VisualBasic' ">$(DefineConstants),REFERENCE_ASSEMBLY=-1</DefineConstants> | ||
<ProduceReferenceAssembly>true</ProduceReferenceAssembly> | ||
<!-- Ref Assms should be determinisitc and not packable, but allow user override --> | ||
<Deterministic Condition="'$(Deterministic)' == ''">true</Deterministic> | ||
<IsPackable Condition="'$(IsPackable)' == ''">false</IsPackable> | ||
</PropertyGroup> | ||
|
||
|
||
<ItemDefinitionGroup> | ||
<ReferenceAssemblyProjectReference> | ||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly> | ||
<GlobalPropertiesToRemove>TargetFramework;RuntimeIdentifier</GlobalPropertiesToRemove> | ||
</ReferenceAssemblyProjectReference> | ||
</ItemDefinitionGroup> | ||
|
||
<!-- This target is called by the source project into the reference assembly project to get the reference assembly output items --> | ||
<Target Name="_SdkGetReferenceAssemblies" DependsOnTargets="Build" Returns="@(ReferenceAssembliesOutput)"> | ||
<ItemGroup> | ||
<ReferenceAssembliesOutput Include="@(IntermediateRefAssembly->'%(FullPath)')" TargetFramework="$(TargetFramework)" /> | ||
<ReferenceAssembliesOutput Include="@(DocumentationProjectOutputGroupOutput->'%(FullPath)')" TargetFramework="$(TargetFramework)" /> | ||
</ItemGroup> | ||
</Target> | ||
|
||
<!-- If we have any ReferenceAssemblyProjectReference items, ensure restore is called on them --> | ||
<Target Name="_ExtrasRestoreReferenceAssembly" AfterTargets="_LoadRestoreGraphEntryPoints" BeforeTargets="_FilterRestoreGraphProjectInputItems"> | ||
<PropertyGroup> | ||
<_ExtrasHasReferenceAssembly Condition="'@(ReferenceAssemblyProjectReference)' != ''">true</_ExtrasHasReferenceAssembly> | ||
<_ExtrasHasReferenceAssembly Condition="'$(_ExtrasHasReferenceAssembly)' == ''">false</_ExtrasHasReferenceAssembly> | ||
</PropertyGroup> | ||
|
||
|
||
<ItemGroup Condition="'$(_ExtrasHasReferenceAssembly)' == 'true' "> | ||
<RestoreGraphProjectInputItems Include="@(ReferenceAssemblyProjectReference->'%(FullPath)')" /> | ||
</ItemGroup> | ||
</Target> | ||
|
||
<!-- Pass clean to reference assm --> | ||
<Target Name="_ExtrasCoreClean" BeforeTargets="CoreClean"> | ||
<PropertyGroup> | ||
<_ExtrasHasReferenceAssembly Condition="'@(ReferenceAssemblyProjectReference)' != ''">true</_ExtrasHasReferenceAssembly> | ||
<_ExtrasHasReferenceAssembly Condition="'$(_ExtrasHasReferenceAssembly)' == ''">false</_ExtrasHasReferenceAssembly> | ||
</PropertyGroup> | ||
|
||
<MSBuild Projects="@(ReferenceAssemblyProjectReference->'%(FullPath)')" | ||
Condition="'$(_ExtrasHasReferenceAssembly)' == 'true'" | ||
BuildInParallel="$(BuildInParallel)" | ||
ContinueOnError="!$(BuildingProject)" | ||
Targets="Clean" | ||
Properties="AssemblyName=$(AssemblyName);Version=$(Version);AssemblyTitle=$(AssemblyTitle);ExtrasIsReferenceAssembly=true" | ||
RemoveProperties="TargetFramework;RuntimeIdentifier" | ||
|
||
/> | ||
</Target> | ||
|
||
<!-- Pass Build to reference assm --> | ||
<!-- Note: this will build once per inner build. Up-to-date checks should prevent issues --> | ||
<Target Name="_ExtrasCoreBuild" BeforeTargets="CoreBuild" DependsOnTargets="GetAssemblyAttributes"> | ||
<PropertyGroup> | ||
<_ExtrasHasReferenceAssembly Condition="'@(ReferenceAssemblyProjectReference)' != ''">true</_ExtrasHasReferenceAssembly> | ||
<_ExtrasHasReferenceAssembly Condition="'$(_ExtrasHasReferenceAssembly)' == ''">false</_ExtrasHasReferenceAssembly> | ||
</PropertyGroup> | ||
|
||
<ItemGroup Condition="'$(AssemblyOriginatorKeyFile)' != '' "> | ||
<_SdkAssemblyKeyFile Include="$(AssemblyOriginatorKeyFile)" /> | ||
<_SdkAssemblyKeyFileFull Include="@(_SdkAssemblyKeyFile->'%(FullPath)')"/> | ||
</ItemGroup> | ||
|
||
<PropertyGroup Condition="'$(AssemblyOriginatorKeyFile)' != '' "> | ||
<_SdkAssemblyKeyFileFullProp>@(_SdkAssemblyKeyFileFull)</_SdkAssemblyKeyFileFullProp> | ||
</PropertyGroup> | ||
<MSBuild Projects="@(ReferenceAssemblyProjectReference->'%(FullPath)')" | ||
Condition="'$(_ExtrasHasReferenceAssembly)' == 'true'" | ||
BuildInParallel="$(BuildInParallel)" | ||
ContinueOnError="!$(BuildingProject)" | ||
Targets="Build" | ||
Properties="AssemblyName=$(AssemblyName);NeutralLanguage=$(NeutralLanguage);AssemblyVersion=$(AssemblyVersion);FileVersion=$(FileVersion);InformationalVersion=$(InformationalVersion);DelaySign=$(DelaySign);SignAssembly=$(SignAssembly);AssemblyOriginatorKeyFile=$(_SdkAssemblyKeyFileFullProp);GenerateDocumentationFile=$(GenerateDocumentationFile);ExtrasIsReferenceAssembly=true" | ||
RemoveProperties="TargetFramework;RuntimeIdentifier" | ||
|
||
/> | ||
</Target> | ||
|
||
<!-- Pack Refs correctly --> | ||
<Target Name="_ExtrasGetRefsForPackage" | ||
BeforeTargets="_GetPackageFiles"> | ||
|
||
<PropertyGroup> | ||
<_ExtrasHasReferenceAssembly Condition="'@(ReferenceAssemblyProjectReference)' != ''">true</_ExtrasHasReferenceAssembly> | ||
<_ExtrasHasReferenceAssembly Condition="'$(_ExtrasHasReferenceAssembly)' == ''">false</_ExtrasHasReferenceAssembly> | ||
</PropertyGroup> | ||
|
||
<ItemGroup Condition="'$(AssemblyOriginatorKeyFile)' != '' "> | ||
<_SdkAssemblyKeyFile Include="$(AssemblyOriginatorKeyFile)" /> | ||
<_SdkAssemblyKeyFileFull Include="@(_SdkAssemblyKeyFile->'%(FullPath)')"/> | ||
</ItemGroup> | ||
|
||
<PropertyGroup Condition="'$(AssemblyOriginatorKeyFile)' != '' "> | ||
<_SdkAssemblyKeyFileFullProp>@(_SdkAssemblyKeyFileFull)</_SdkAssemblyKeyFileFullProp> | ||
</PropertyGroup> | ||
|
||
<MSBuild Projects="@(ReferenceAssemblyProjectReference->'%(FullPath)')" | ||
Properties="ExtrasIsReferenceAssembly=true" | ||
Condition="'$(_ExtrasHasReferenceAssembly)' == 'true'" | ||
Targets="_GetTargetFrameworksOutput"> | ||
|
||
<Output TaskParameter="TargetOutputs" | ||
ItemName="_RefTargetFrameworks" /> | ||
</MSBuild> | ||
|
||
<MSBuild Projects="@(ReferenceAssemblyProjectReference->'%(FullPath)')" | ||
Condition="'$(_ExtrasHasReferenceAssembly)' == 'true'" | ||
Targets="_SdkGetReferenceAssemblies" | ||
Properties="TargetFramework=%(_RefTargetFrameworks.Identity);AssemblyName=$(AssemblyName);NeutralLanguage=$(NeutralLanguage);AssemblyVersion=$(AssemblyVersion);FileVersion=$(FileVersion);InformationalVersion=$(InformationalVersion);DelaySign=$(DelaySign);SignAssembly=$(SignAssembly);AssemblyOriginatorKeyFile=$(_SdkAssemblyKeyFileFullProp);GenerateDocumentationFile=$(GenerateDocumentationFile);ExtrasIsReferenceAssembly=true" | ||
> | ||
|
||
<Output TaskParameter="TargetOutputs" | ||
ItemName="_ExtrasRefAssmOutputs" /> | ||
</MSBuild> | ||
|
||
<ItemGroup> | ||
<None Include="@(_ExtrasRefAssmOutputs)" PackagePath="ref/%(_ExtrasRefAssmOutputs.TargetFramework)" Pack="true" /> | ||
</ItemGroup> | ||
|
||
</Target> | ||
|
||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<Import Project="$(MSBuildThisFileDirectory)..\..\Source\MSBuild.Sdk.Extras\BuildMultiTargeting\MSBuild.Sdk.Extras.props" /> | ||
|
||
<PropertyGroup> | ||
<!--<TargetFramework>uap10.0</TargetFramework>--> | ||
<TargetFrameworks>netstandard1.4;netstandard2.0</TargetFrameworks> | ||
</PropertyGroup> | ||
|
||
|
||
<ItemGroup> | ||
<Compile Include="..\ClassLibrary\**\*.cs" Exclude="..\ClassLibrary\obj\**" /> | ||
</ItemGroup> | ||
|
||
<Import Project="$(MSBuildSDKExtrasTargets)" Condition="Exists('$(MSBuildSDKExtrasTargets)')" /> | ||
<Import Project="$(MSBuildThisFileDirectory)..\..\Source\MSBuild.Sdk.Extras\BuildMultiTargeting\MSBuild.Sdk.Extras.targets" /> | ||
<Import Project="..\Test.targets" /> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
using System; | ||
|
||
namespace MSBuild.NET.Sdk.Tests | ||
namespace MSBuild.Sdk.Extras.Tests | ||
{ | ||
public class Class | ||
{ | ||
int SomeMethod(int a, int b) => a + b; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<Project> | ||
|
||
<Import Project="$(MSBuildThisFileDirectory)..\..\Source\MSBuild.Sdk.Extras\Sdk\Sdk.props" /> | ||
|
||
<PropertyGroup> | ||
<!--<TargetFramework>uap10.0</TargetFramework>--> | ||
<TargetFrameworks>netstandard1.4;netstandard2.0</TargetFrameworks> | ||
<IsPackable>false</IsPackable> | ||
<ExtrasIsReferenceAssembly>true</ExtrasIsReferenceAssembly> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="..\ClassLibraryAsSdk\**\*.cs" Exclude="..\ClassLibraryAsSdk\obj\**" /> | ||
</ItemGroup> | ||
|
||
<Import Project="$(MSBuildThisFileDirectory)..\..\Source\MSBuild.Sdk.Extras\Sdk\Sdk.targets" /> | ||
<Import Project="..\Test.targets" /> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
using System; | ||
|
||
namespace MSBuild.NET.Sdk.Tests | ||
namespace MSBuild.Sdk.Extras.Tests | ||
{ | ||
public class Class | ||
{ | ||
} | ||
int SomeMethod(int a, int b) => a + b; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters