Xamarin Public Jenkins (auto-signing) 966bba02bb Imported Upstream version 5.2.0.175
Former-commit-id: bb0468d0f257ff100aa895eb5fe583fb5dfbf900
2017-06-07 13:16:24 +00:00

63 lines
3.6 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--
We should be using $(BuildToolsTaskDir) for this, however we are currently forcing that property to
always be net45 (because we use Mono to run our tests and Mono needs to load the net45 version)
-->
<PropertyGroup>
<CodeAnalyzerDir Condition="'$(CodeAnalyzerDir)'=='' and '$(RunningOnCore)'!='true'">$(ToolsDir)net46/analyzers/</CodeAnalyzerDir>
<CodeAnalyzerDir Condition="'$(CodeAnalyzerDir)'=='' and '$(RunningOnCore)'=='true'">$(ToolsDir)analyzers/</CodeAnalyzerDir>
</PropertyGroup>
<!-- PInvokeChecker data files-->
<PropertyGroup Condition="'$(OSGroup)'=='Windows_NT' and '$(EnableDotnetAnalyzers)' == 'true'">
<!-- Just validate for OneCore: default -->
<ValidPInvokeMappings>$(MSBuildThisFileDirectory)PinvokeAnalyzer_Win32Apis.txt</ValidPInvokeMappings>
<!-- Further restrict to API allowed for UWP -->
<EnablePinvokeUWPAnalyzer Condition="'$(EnablePinvokeUWPAnalyzer)' == ''">true</EnablePinvokeUWPAnalyzer>
<ValidPInvokeMappings Condition="'$(UWPCompatible)'=='true' and '$(EnablePinvokeUWPAnalyzer)' == 'true'">$(MSBuildThisFileDirectory)PinvokeAnalyzer_Win32UWPApis.txt</ValidPInvokeMappings>
</PropertyGroup>
<PropertyGroup>
<!-- %24 = $ -->
<EnableFxCopAnalyzers Condition="$([System.Text.RegularExpressions.Regex]::IsMatch($(MSBuildProjectDirectory), 'src%24'))">true</EnableFxCopAnalyzers>
<EnableFxCopAnalyzers Condition="'$(EnableFxCopAnalyzers)' != 'true'">false</EnableFxCopAnalyzers>
</PropertyGroup>
<ItemGroup Condition="$(EnableFxCopAnalyzers)">
<Analyzer Include="$(CodeAnalyzerDir)*.dll" Exclude="$(CodeAnalyzerDir)Microsoft.DotNet.CodeAnalysis.dll"/>
</ItemGroup>
<PropertyGroup Condition="$(EnableFxCopAnalyzers)">
<CodeAnalysisRuleSet Condition="'$(CodeAnalysisRuleSet)' == ''">$(MSBuildThisFileDirectory)Default.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup>
<EnablePInvokeAnalyzer Condition="'$(EnablePInvokeAnalyzer)' == ''">true</EnablePInvokeAnalyzer>
</PropertyGroup>
<ItemGroup Condition="'$(EnableDotnetAnalyzers)' == 'true'">
<!-- Enable the Microsoft.Dotnet.CodeAnalysis.dll analyzer -->
<Analyzer Include="$(CodeAnalyzerDir)Microsoft.DotNet.CodeAnalysis.dll"/>
<AdditionalFiles Include="$(MSBuildProjectDirectory)/*.analyzerdata" />
<AdditionalFiles Include="$(MSBuildProjectDirectory)/*.analyzerdata.$(Platform)" />
<!-- Add the necessary valid Pinvoke mapping file -->
<AdditionalFiles Condition="'$(ValidPInvokeMappings)' != ''" Include="$(ValidPInvokeMappings)"/>
<!-- Disable any analyzers that should not run -->
<DisabledAnalyzers Condition="'$(IsTestProject)' == 'true' or '$(TargetsUnix)' == 'true' or '$(EnablePInvokeAnalyzer)' != 'true'" Include="PInvokeAnalyzer"/>
<DisabledAnalyzers Condition="'$(TargetsWindows)'=='true' and ($(TargetGroup.Contains('net46')) or $(TargetGroup.Contains('net45')))" Include="PInvokeAnalyzer" />
</ItemGroup>
<!-- If we have specified any analyzers that need to be disabled write them into the file -->
<Target Name="GenerateAnalyzerConfigFile" BeforeTargets="CoreCompile" Condition="'@(DisabledAnalyzers)'!='' and '$(EnableDotnetAnalyzers)' == 'true'" >
<WriteLinesToFile File="$(IntermediateOutputPath)/disabledAnalyzers.config" Lines="@(DisabledAnalyzers)" Overwrite="true" />
<ItemGroup>
<AdditionalFiles Include="$(IntermediateOutputPath)/disabledAnalyzers.config"/>
<FileWrites Include="$(IntermediateOutputPath)/disabledAnalyzers.config"/>
</ItemGroup>
</Target>
</Project>