OpenAPI.NET.OData/tool/After.Common.targets

105 lines
5 KiB
XML

<!--
This file defines the common targets before the build.
This file might be updated by automation.
-->
<Project>
<!-- Ensures that if this file changes it forces a rebuild -->
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<PropertyGroup>
<BuildDependsOn>
GenerateAssemblyAttributeFile;
ExcludeAssemblyFilesFromSourceAnalysis;
$(BuildDependsOn);
</BuildDependsOn>
</PropertyGroup>
<Target Name="AfterBuild" DependsOnTargets="$(AfterBuildDependsOn)"/>
<!-- ********************************************************************************************* -->
<!-- ********************************************************************************************* -->
<!-- *** Exclude certain files globally from source analysis. In previous build system, these files-->
<!-- *** were globally excluded in a edit to StyleCop.targets. This replicates the same behavior. -->
<!-- ********************************************************************************************* -->
<Target Name="ExcludeAssemblyFilesFromSourceAnalysis">
<ItemGroup>
<Compile Condition="'%(Filename)%(Extension)'=='OpenApiODataAssemblyAttributes.cs'
or '%(Filename)%(Extension)'=='AssemblyRefs.cs'
or '%(Filename)%(Extension)'=='.NETFramework,Version=v4.0.AssemblyAttributes.cs'
or '%(Filename)%(Extension)'=='PlatformHelper.cs'
or '%(Filename)%(Extension)'=='VersionConstants.cs'
or '%(Filename)%(Extension)'=='AssemblyMetadataAttribute.cs'">
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
</Compile>
</ItemGroup>
</Target>
<!-- ********************************************************************************************* -->
<!-- ********************************************************************************************* -->
<!-- *** Generate a file with assembly attributes and hook it into the build -->
<!-- ********************************************************************************************* -->
<Target Name="GenerateAssemblyAttributeFile"
Inputs="$(MSBuildProjectFile);$(EnlistToolPath)\versioning.props"
Outputs="$(IntermediateOutputPath.TrimEnd('\'))\OpenApiODataAssemblyAttributes$(DefaultLanguageSourceExtension)"
Condition="'$(ShouldGenerateAssemblyAttributeFile)' == 'true'">
<PropertyGroup>
<!--Add more templates if we generate AssemblyAttribute files for other project types.-->
<GenerateAssemblyAttributeTemplate>UNDEFINED_GenerateAssemblyAttributeTemplate</GenerateAssemblyAttributeTemplate>
<GenerateAssemblyAttributeTemplateCSharp>
using System.Reflection;
using System.Resources;
[assembly: AssemblyDescription("%AssemblyNameFull%")]
[assembly: AssemblyTitle("%AssemblyNameFull%")]
[assembly: AssemblyDefaultAlias("%AssemblyNameFull%")]
[assembly: AssemblyFileVersion("%VersionFull%")]
[assembly: AssemblyInformationalVersion("%VersionFull%")]
[assembly: AssemblyVersion("%VersionFullSemantic%")]
[assembly: SatelliteContractVersion("%VersionFull%")]
[assembly: AssemblyMetadata("Serviceable", "True")]
</GenerateAssemblyAttributeTemplateCSharp>
</PropertyGroup>
<PropertyGroup>
<GenerateAssemblyAttributeTemplate>$(GenerateAssemblyAttributeTemplateCSharp)</GenerateAssemblyAttributeTemplate>
</PropertyGroup>
<PropertyGroup>
<AssemblyAttributeOutputFile>$(IntermediateOutputPath.TrimEnd("\\"))\OpenApiODataAssemblyAttributes$(DefaultLanguageSourceExtension)</AssemblyAttributeOutputFile>
<AssemblyNameFull>$(AssemblyName)$(TargetExt)</AssemblyNameFull>
<AssemblyAttributeFileContentsTransformed>$([System.String]::Copy('$(GenerateAssemblyAttributeTemplate)').Replace("%25AssemblyNameFull%25",$(AssemblyNameFull)).Replace("%25VersionFull%25",$(VersionFull)).Replace("%25VersionFullSemantic%25",$(VersionFullSemantic)))</AssemblyAttributeFileContentsTransformed>
</PropertyGroup>
<Message Text="GenerateAssemblyAttributeFile: Generating $(AssemblyAttributeOutputFile)" Importance="high" Condition="'$(DebugMessages)' == 'true'"/>
<MakeDir Directories="$(IntermediateOutputPath)" Condition="!Exists($(IntermediateOutputPath))"/>
<WriteLinesToFile
File="$(AssemblyAttributeOutputFile)"
Lines="$(AssemblyAttributeFileContentsTransformed)"
Overwrite="true"
Encoding="Unicode"
ContinueOnError="false"/>
<ItemGroup>
<Compile Include="$(AssemblyAttributeOutputFile)" />
</ItemGroup>
</Target>
<!-- ********************************************************************************************* -->
<!-- Execute StyleCop for each project -->
<Import Project="$(StyleCopTargets)" Condition="Exists('$(StyleCopTargets)') and '$(RunStyleCop)' == 'true' and '$(EnableStyleCop)' == 'true'"/>
<!-- Chain into the defaults from the toolset -->
<Import Condition="'$(DefaultCustomAfterMicrosoftCommonTargets)' != ''" Project="$(DefaultCustomAfterMicrosoftCommonTargets)" />
</Project>