diff options
Diffstat (limited to 'Tools/GenerateAssemblyInfo.Sdk.targets')
-rwxr-xr-x | Tools/GenerateAssemblyInfo.Sdk.targets | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/Tools/GenerateAssemblyInfo.Sdk.targets b/Tools/GenerateAssemblyInfo.Sdk.targets new file mode 100755 index 0000000000..7c79585f1b --- /dev/null +++ b/Tools/GenerateAssemblyInfo.Sdk.targets @@ -0,0 +1,66 @@ +<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + + <PropertyGroup> + <!-- BuildTools never generated this attribute before, so don't let the SDK generate it. --> + <GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> + + <!-- + When using the Microsoft.NET.Sdk, Company and Product are defaulted to $(AssemblyName) + in Microsoft.NET.Sdk.BeforeCommon.targets, which means we would have to default them in + a props file. However, the versioning.props file has to be imported during versioning.targets + in order to get all the version properties set correctly. + So overwrite these two properties here, so they are set correctly. + --> + <Company>Microsoft Corporation</Company> + <Product>Microsoft%AE .NET Core</Product> + </PropertyGroup> + + <Target Name="_ComputeBuildToolsAssemblyInfoAttributes" + DependsOnTargets="CreateVersionFileDuringBuild;DecideIfWeNeedToIncludeDllSafeSearchPathAttribute" + BeforeTargets="GetAssemblyAttributes"> + <ItemGroup> + <AssemblyAttribute Include="System.Reflection.AssemblyDefaultAliasAttribute"> + <_Parameter1>$(AssemblyName)</_Parameter1> + </AssemblyAttribute> + + <AssemblyAttribute Include="System.Reflection.AssemblyMetadata" + Condition="'$(SkipFrameworkAssemblyMetadata)' != 'true' and '@(AssemblyMetadata)' != ''"> + <_Parameter1>%(AssemblyMetadata.Identity)</_Parameter1> + <_Parameter2>%(AssemblyMetadata.Value)</_Parameter2> + </AssemblyAttribute> + </ItemGroup> + </Target> + + <!-- Work around https://github.com/Microsoft/msbuild/issues/3412 by writing the non-string assembly attributes manually --> + <!-- Note: ReferenceAssemblies.targets still uses @(AssemblyInfoLines) as well. So if you remove this, those need to migrate too. --> + <Target Name="_WriteNonStringAssemblyInfoAttributes" + AfterTargets="CoreGenerateAssemblyInfo" + Inputs="$(MSBuildProjectFile)" + Outputs="$(AssemblyInfoFile)"> + + <ItemGroup Condition="'$(MSBuildProjectExtension)' == '.csproj'"> + <AssemblyInfoLines Condition="'$(CLSCompliant)'=='true'" Include="[assembly:System.CLSCompliant(true)]" /> + + <AssemblyInfoLines Condition="'$(IncludeDllSafeSearchPathAttribute)'=='true'" + Include="[assembly: System.Runtime.InteropServices.DefaultDllImportSearchPathsAttribute(System.Runtime.InteropServices.DllImportSearchPath.AssemblyDirectory | System.Runtime.InteropServices.DllImportSearchPath.System32)]" /> + </ItemGroup> + + <ItemGroup Condition="'$(MSBuildProjectExtension)' == '.vbproj'"> + <AssemblyInfoLines Condition="'$(CLSCompliant)'=='true'" Include="<Assembly:System.CLSCompliant(True)>" /> + + <AssemblyInfoLines Condition="'$(IncludeDllSafeSearchPathAttribute)'=='true'" + Include="<Assembly:System.Runtime.InteropServices.DefaultDllImportSearchPathsAttribute(System.Runtime.InteropServices.DllImportSearchPath.AssemblyDirectory | System.Runtime.InteropServices.DllImportSearchPath.System32)>" /> + </ItemGroup> + + <WriteLinesToFile File="$(AssemblyInfoFile)" + Lines="@(AssemblyInfoLines)" + Condition="'@(AssemblyInfoLines)' != ''" + Overwrite="true" /> + + <ItemGroup Condition="'@(AssemblyInfoLines)' != ''"> + <Compile Include="$(AssemblyInfoFile)" /> + <FileWrites Include="$(AssemblyInfoFile)" /> + </ItemGroup> + </Target> + +</Project> |