Spaces:
Sleeping
Sleeping
<!-- | |
*********************************************************************************************** | |
Microsoft.NET.GenerateAssemblyInfo.targets | |
WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have | |
created a backup copy. Incorrect changes to this file will make it | |
impossible to load or build your projects from the command-line or the IDE. | |
Copyright (c) .NET Foundation. All rights reserved. | |
*********************************************************************************************** | |
--> | |
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
<!-- | |
============================================================ | |
GenerateAssemblyInfo | |
Generates assembly info source to intermediate directory | |
============================================================ | |
--> | |
<PropertyGroup> | |
<GeneratedAssemblyInfoFile Condition="'$(GeneratedAssemblyInfoFile)' ==''">$(IntermediateOutputPath)$(MSBuildProjectName).AssemblyInfo$(DefaultLanguageSourceExtension)</GeneratedAssemblyInfoFile> | |
<GenerateAssemblyInfo Condition="'$(GenerateAssemblyInfo)' == ''">true</GenerateAssemblyInfo> | |
</PropertyGroup> | |
<PropertyGroup Condition="'$(GenerateAssemblyInfo)' == 'true'"> | |
<GenerateAssemblyCompanyAttribute Condition="'$(GenerateAssemblyCompanyAttribute)' == ''">true</GenerateAssemblyCompanyAttribute> | |
<GenerateAssemblyConfigurationAttribute Condition="'$(GenerateAssemblyConfigurationAttribute)' == ''">true</GenerateAssemblyConfigurationAttribute> | |
<GenerateAssemblyCopyrightAttribute Condition="'$(GenerateAssemblyCopyrightAttribute)' == ''">true</GenerateAssemblyCopyrightAttribute> | |
<GenerateAssemblyDescriptionAttribute Condition="'$(GenerateAssemblyDescriptionAttribute)' == ''">true</GenerateAssemblyDescriptionAttribute> | |
<GenerateAssemblyFileVersionAttribute Condition="'$(GenerateAssemblyFileVersionAttribute)' == ''">true</GenerateAssemblyFileVersionAttribute> | |
<GenerateAssemblyInformationalVersionAttribute Condition="'$(GenerateAssemblyInformationalVersionAttribute)' == ''">true</GenerateAssemblyInformationalVersionAttribute> | |
<GenerateAssemblyTrademarkAttribute Condition="'$(GenerateAssemblyTrademarkAttribute)' == ''">true</GenerateAssemblyTrademarkAttribute> | |
<GenerateAssemblyProductAttribute Condition="'$(GenerateAssemblyProductAttribute)' == ''">true</GenerateAssemblyProductAttribute> | |
<GenerateAssemblyTitleAttribute Condition="'$(GenerateAssemblyTitleAttribute)' == ''">true</GenerateAssemblyTitleAttribute> | |
<GenerateAssemblyVersionAttribute Condition="'$(GenerateAssemblyVersionAttribute)' == ''">true</GenerateAssemblyVersionAttribute> | |
<GenerateRepositoryUrlAttribute Condition="'$(GenerateRepositoryUrlAttribute)' == '' and !('$(TargetFrameworkIdentifier)' == '.NETFramework' and $([MSBuild]::VersionLessThan($(TargetFrameworkVersion), 4.5)))">true</GenerateRepositoryUrlAttribute> | |
<GenerateNeutralResourcesLanguageAttribute Condition="'$(GenerateNeutralResourcesLanguageAttribute)' == ''">true</GenerateNeutralResourcesLanguageAttribute> | |
<GenerateAssemblyMetadataAttributes Condition="'$(GenerateAssemblyMetadataAttributes)' == ''">true</GenerateAssemblyMetadataAttributes> | |
<IncludeSourceRevisionInInformationalVersion Condition="'$(IncludeSourceRevisionInInformationalVersion)' == ''">true</IncludeSourceRevisionInInformationalVersion> | |
<GenerateInternalsVisibleToAttributes Condition="'$(GenerateInternalsVisibleToAttributes)' == ''">true</GenerateInternalsVisibleToAttributes> | |
<GenerateRequiresPreviewFeaturesAttribute Condition="'$(GenerateRequiresPreviewFeaturesAttribute)' == '' and '$(IsNetCoreAppTargetingLatestTFM)' == 'true'">true</GenerateRequiresPreviewFeaturesAttribute> | |
<GenerateTargetPlatformAttribute Condition="'$(GenerateTargetPlatformAttribute)' == ''">true</GenerateTargetPlatformAttribute> | |
<GenerateSupportedOSPlatformAttribute Condition="'$(GenerateSupportedOSPlatformAttribute)' == ''">true</GenerateSupportedOSPlatformAttribute> | |
<GenerateDisableRuntimeMarshallingAttribute Condition="'$(GenerateDisableRuntimeMarshallingAttribute)' == ''">true</GenerateDisableRuntimeMarshallingAttribute> | |
</PropertyGroup> | |
<!-- | |
Note that this must run before every invocation of CoreCompile to ensure that all compiler | |
runs see the generated assembly info. There is at least one scenario involving Xaml | |
where CoreCompile is invoked without other potential hooks such as Compile or CoreBuild, | |
etc., so we hook directly on to CoreCompile. Furthermore, we must run *after* | |
PrepareForBuild to ensure that the intermediate directory has been created. | |
Targets that generate Compile items are also expected to run before | |
BeforeCompile targets (common targets convention). | |
--> | |
<Target Name="GenerateAssemblyInfo" | |
BeforeTargets="BeforeCompile;CoreCompile" | |
DependsOnTargets="PrepareForBuild;CoreGenerateAssemblyInfo" | |
Condition="'$(GenerateAssemblyInfo)' == 'true'" /> | |
<Target Name="AddSourceRevisionToInformationalVersion" | |
DependsOnTargets="GetAssemblyVersion;InitializeSourceControlInformation" | |
Condition="'$(SourceControlInformationFeatureSupported)' == 'true' and '$(IncludeSourceRevisionInInformationalVersion)' == 'true'"> | |
<PropertyGroup Condition="'$(SourceRevisionId)' != ''"> | |
<!-- Follow SemVer 2.0 rules --> | |
<_InformationalVersionContainsPlus>false</_InformationalVersionContainsPlus> | |
<_InformationalVersionContainsPlus Condition="$(InformationalVersion.Contains('+'))">true</_InformationalVersionContainsPlus> | |
<InformationalVersion Condition="!$(_InformationalVersionContainsPlus)">$(InformationalVersion)+$(SourceRevisionId)</InformationalVersion> | |
<InformationalVersion Condition="$(_InformationalVersionContainsPlus)">$(InformationalVersion).$(SourceRevisionId)</InformationalVersion> | |
</PropertyGroup> | |
</Target> | |
<Target Name="GetAssemblyAttributes" | |
DependsOnTargets="GetAssemblyVersion;AddSourceRevisionToInformationalVersion"> | |
<ItemGroup> | |
<AssemblyAttribute Include="System.Reflection.AssemblyCompanyAttribute" Condition="'$(Company)' != '' and '$(GenerateAssemblyCompanyAttribute)' == 'true'"> | |
<_Parameter1>$(Company)</_Parameter1> | |
</AssemblyAttribute> | |
<AssemblyAttribute Include="System.Reflection.AssemblyConfigurationAttribute" Condition="'$(Configuration)' != '' and '$(GenerateAssemblyConfigurationAttribute)' == 'true'"> | |
<_Parameter1>$(Configuration)</_Parameter1> | |
</AssemblyAttribute> | |
<AssemblyAttribute Include="System.Reflection.AssemblyCopyrightAttribute" Condition="'$(Copyright)' != '' and '$(GenerateAssemblyCopyrightAttribute)' == 'true'"> | |
<_Parameter1>$(Copyright)</_Parameter1> | |
</AssemblyAttribute> | |
<AssemblyAttribute Include="System.Reflection.AssemblyDescriptionAttribute" Condition="'$(Description)' != '' and '$(GenerateAssemblyDescriptionAttribute)' == 'true'"> | |
<_Parameter1>$(Description)</_Parameter1> | |
</AssemblyAttribute> | |
<AssemblyAttribute Include="System.Reflection.AssemblyFileVersionAttribute" Condition="'$(FileVersion)' != '' and '$(GenerateAssemblyFileVersionAttribute)' == 'true'"> | |
<_Parameter1>$(FileVersion)</_Parameter1> | |
</AssemblyAttribute> | |
<AssemblyAttribute Include="System.Reflection.AssemblyInformationalVersionAttribute" Condition="'$(InformationalVersion)' != '' and '$(GenerateAssemblyInformationalVersionAttribute)' == 'true'"> | |
<_Parameter1>$(InformationalVersion)</_Parameter1> | |
</AssemblyAttribute> | |
<AssemblyAttribute Include="System.Reflection.AssemblyProductAttribute" Condition="'$(Product)' != '' and '$(GenerateAssemblyProductAttribute)' == 'true'"> | |
<_Parameter1>$(Product)</_Parameter1> | |
</AssemblyAttribute> | |
<AssemblyAttribute Include="System.Reflection.AssemblyTrademarkAttribute" Condition="'$(Trademark)' != '' and '$(GenerateAssemblyTrademarkAttribute)' == 'true'"> | |
<_Parameter1>$(Trademark)</_Parameter1> | |
</AssemblyAttribute> | |
<AssemblyAttribute Include="System.Reflection.AssemblyTitleAttribute" Condition="'$(AssemblyTitle)' != '' and '$(GenerateAssemblyTitleAttribute)' == 'true'"> | |
<_Parameter1>$(AssemblyTitle)</_Parameter1> | |
</AssemblyAttribute> | |
<AssemblyAttribute Include="System.Reflection.AssemblyVersionAttribute" Condition="'$(AssemblyVersion)' != '' and '$(GenerateAssemblyVersionAttribute)' == 'true'"> | |
<_Parameter1>$(AssemblyVersion)</_Parameter1> | |
</AssemblyAttribute> | |
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute" Condition="'$(GenerateRepositoryUrlAttribute)' == 'true' and ('$(RepositoryUrl)' != '' or '$(PublishRepositoryUrl)' == 'true')" > | |
<_Parameter1>RepositoryUrl</_Parameter1> | |
<_Parameter2 Condition="'$(RepositoryUrl)' != ''">$(RepositoryUrl)</_Parameter2> | |
<_Parameter2 Condition="'$(RepositoryUrl)' == ''">$(PrivateRepositoryUrl)</_Parameter2> | |
</AssemblyAttribute> | |
<AssemblyAttribute Include="System.Resources.NeutralResourcesLanguageAttribute" Condition="'$(NeutralLanguage)' != '' and '$(GenerateNeutralResourcesLanguageAttribute)' == 'true'"> | |
<_Parameter1>$(NeutralLanguage)</_Parameter1> | |
</AssemblyAttribute> | |
<InternalsVisibleTo Condition="'%(InternalsVisibleTo.PublicKey)' != ''"> | |
<Key>%(InternalsVisibleTo.PublicKey)</Key> | |
</InternalsVisibleTo> | |
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo" Condition="%(InternalsVisibleTo.Identity) != '' and '$(GenerateInternalsVisibleToAttributes)' == 'true'"> | |
<_Parameter1 Condition="'%(InternalsVisibleTo.Key)' != ''">%(InternalsVisibleTo.Identity), PublicKey=%(InternalsVisibleTo.Key)</_Parameter1> | |
<_Parameter1 Condition="'%(InternalsVisibleTo.Key)' == '' and '$(PublicKey)' != ''">%(InternalsVisibleTo.Identity), PublicKey=$(PublicKey)</_Parameter1> | |
<_Parameter1 Condition="'%(InternalsVisibleTo.Key)' == '' and '$(PublicKey)' == ''">%(InternalsVisibleTo.Identity)</_Parameter1> | |
</AssemblyAttribute> | |
<AssemblyAttribute Include="System.Reflection.AssemblyMetadata" Condition="%(AssemblyMetadata.Identity) != '' and '$(GenerateAssemblyMetadataAttributes)' == 'true'"> | |
<_Parameter1>%(AssemblyMetadata.Identity)</_Parameter1> | |
<_Parameter2>%(AssemblyMetadata.Value)</_Parameter2> | |
</AssemblyAttribute> | |
<AssemblyAttribute Include="System.Runtime.Versioning.RequiresPreviewFeaturesAttribute" Condition="'$(EnablePreviewFeatures)' == 'true' and '$(GenerateRequiresPreviewFeaturesAttribute)' == 'true'"> | |
</AssemblyAttribute> | |
</ItemGroup> | |
<ItemGroup Condition="'$(GenerateTargetPlatformAttribute)' == 'true' | |
and '$(TargetPlatformIdentifier)' != '' | |
and '$(TargetPlatformVersion)' != '' | |
and '$(TargetFrameworkIdentifier)' == '.NETCoreApp' | |
and $([MSBuild]::VersionGreaterThanOrEquals($(_TargetFrameworkVersionWithoutV), '5.0'))"> | |
<AssemblyAttribute Include="System.Runtime.Versioning.TargetPlatformAttribute"> | |
<_Parameter1>$(TargetPlatformIdentifier)$(TargetPlatformVersion)</_Parameter1> | |
</AssemblyAttribute> | |
</ItemGroup> | |
<ItemGroup Condition="'$(GenerateSupportedOSPlatformAttribute)' == 'true' | |
and '$(TargetPlatformIdentifier)' != '' | |
and '$(SupportedOSPlatformVersion)' != '' | |
and '$(TargetFrameworkIdentifier)' == '.NETCoreApp' | |
and $([MSBuild]::VersionGreaterThanOrEquals($(_TargetFrameworkVersionWithoutV), '5.0'))"> | |
<AssemblyAttribute Include="System.Runtime.Versioning.SupportedOSPlatformAttribute" | |
Condition="!$([MSBuild]::VersionEquals($(SupportedOSPlatformVersion), '0.0'))" > | |
<_Parameter1>$(TargetPlatformIdentifier)$(SupportedOSPlatformVersion)</_Parameter1> | |
</AssemblyAttribute> | |
<AssemblyAttribute Include="System.Runtime.Versioning.SupportedOSPlatformAttribute" | |
Condition="$([MSBuild]::VersionEquals($(SupportedOSPlatformVersion), '0.0'))" > | |
<_Parameter1>$(TargetPlatformIdentifier)</_Parameter1> | |
</AssemblyAttribute> | |
</ItemGroup> | |
<ItemGroup Condition="'$(GenerateDisableRuntimeMarshallingAttribute)' == 'true' | |
and '$(DisableRuntimeMarshalling)' == 'true' | |
and '$(TargetFrameworkIdentifier)' == '.NETCoreApp' | |
and $([MSBuild]::VersionGreaterThanOrEquals($(_TargetFrameworkVersionWithoutV), '7.0'))"> | |
<AssemblyAttribute Include="System.Runtime.CompilerServices.DisableRuntimeMarshallingAttribute"> | |
</AssemblyAttribute> | |
</ItemGroup> | |
</Target> | |
<!-- | |
To allow version changes to be respected on incremental builds (e.g. through CLI parameters), | |
create a hash of all assembly attributes so that the cache file will change with the calculated | |
assembly attribute values and msbuild will then execute CoreGenerateAssembly to generate a new file. | |
--> | |
<Target Name="CreateGeneratedAssemblyInfoInputsCacheFile" | |
DependsOnTargets="GetAssemblyAttributes"> | |
<PropertyGroup> | |
<GeneratedAssemblyInfoInputsCacheFile>$(IntermediateOutputPath)$(MSBuildProjectName).AssemblyInfoInputs.cache</GeneratedAssemblyInfoInputsCacheFile> | |
</PropertyGroup> | |
<!-- We only use up to _Parameter1 for most attributes, but other targets may add additional assembly attributes with multiple parameters. --> | |
<Hash ItemsToHash="@(AssemblyAttribute->'%(Identity)%(_Parameter1)%(_Parameter2)%(_Parameter3)%(_Parameter4)%(_Parameter5)%(_Parameter6)%(_Parameter7)%(_Parameter8)')"> | |
<Output TaskParameter="HashResult" PropertyName="_AssemblyAttributesHash" /> | |
</Hash> | |
<WriteLinesToFile Lines="$(_AssemblyAttributesHash)" File="$(GeneratedAssemblyInfoInputsCacheFile)" Overwrite="True" WriteOnlyWhenDifferent="True" /> | |
<ItemGroup> | |
<FileWrites Include="$(GeneratedAssemblyInfoInputsCacheFile)" /> | |
</ItemGroup> | |
</Target> | |
<Target Name="CoreGenerateAssemblyInfo" | |
Condition="'$(Language)'=='VB' or '$(Language)'=='C#'" | |
DependsOnTargets="CreateGeneratedAssemblyInfoInputsCacheFile" | |
Inputs="$(GeneratedAssemblyInfoInputsCacheFile)" | |
Outputs="$(GeneratedAssemblyInfoFile)"> | |
<ItemGroup> | |
<!-- Ensure the generated assemblyinfo file is not already part of the Compile sources, as a workaround for https://github.com/dotnet/sdk/issues/114 --> | |
<Compile Remove="$(GeneratedAssemblyInfoFile)" /> | |
</ItemGroup> | |
<WriteCodeFragment AssemblyAttributes="@(AssemblyAttribute)" Language="$(Language)" OutputFile="$(GeneratedAssemblyInfoFile)"> | |
<Output TaskParameter="OutputFile" ItemName="Compile" /> | |
<Output TaskParameter="OutputFile" ItemName="FileWrites" /> | |
</WriteCodeFragment> | |
</Target> | |
<!-- | |
================================================================== | |
GetAssemblyVersion | |
Parses the nuget package version set in $(Version) and returns | |
the implied $(AssemblyVersion) and $(FileVersion). | |
e.g.: | |
<Version>1.2.3-beta.4</Version> | |
implies: | |
<AssemblyVersion>1.2.3</AssemblyVersion> | |
<FileVersion>1.2.3</FileVersion> | |
Note that if $(AssemblyVersion) or $(FileVersion) are are already set, it | |
is considered an override of the default inference from $(Version) and they | |
are left unchanged by this target. | |
================================================================== | |
--> | |
<Target Name="GetAssemblyVersion"> | |
<GetAssemblyVersion Condition="'$(AssemblyVersion)' == ''" NuGetVersion="$(Version)"> | |
<Output TaskParameter="AssemblyVersion" PropertyName="AssemblyVersion" /> | |
</GetAssemblyVersion> | |
<PropertyGroup> | |
<FileVersion Condition="'$(FileVersion)' == ''">$(AssemblyVersion)</FileVersion> | |
<InformationalVersion Condition="'$(InformationalVersion)' == ''">$(Version)</InformationalVersion> | |
</PropertyGroup> | |
</Target> | |
</Project> | |