summaryrefslogtreecommitdiff
path: root/packages/microsoft.dotnet.buildtools/2.1.0-rc1-03006-01/lib/codeAnalysis.targets
diff options
context:
space:
mode:
Diffstat (limited to 'packages/microsoft.dotnet.buildtools/2.1.0-rc1-03006-01/lib/codeAnalysis.targets')
-rwxr-xr-xpackages/microsoft.dotnet.buildtools/2.1.0-rc1-03006-01/lib/codeAnalysis.targets69
1 files changed, 69 insertions, 0 deletions
diff --git a/packages/microsoft.dotnet.buildtools/2.1.0-rc1-03006-01/lib/codeAnalysis.targets b/packages/microsoft.dotnet.buildtools/2.1.0-rc1-03006-01/lib/codeAnalysis.targets
new file mode 100755
index 0000000000..856b665534
--- /dev/null
+++ b/packages/microsoft.dotnet.buildtools/2.1.0-rc1-03006-01/lib/codeAnalysis.targets
@@ -0,0 +1,69 @@
+<?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 Condition="'$(EnableFxCopAnalyzers)' == ''">
+ <!-- %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)" />
+ <AdditionalFiles Include="$(MSBuildProjectDirectory)/*.analyzerdata.$(TargetGroup)" />
+
+ <!-- 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'" >
+ <!-- Write the file only if it changed -->
+ <ReadLinesFromFile File="$(IntermediateOutputPath)/disabledAnalyzers.config">
+ <Output TaskParameter="Lines" ItemName="_DisabledAnalyzers" />
+ </ReadLinesFromFile>
+
+ <WriteLinesToFile File="$(IntermediateOutputPath)/disabledAnalyzers.config" Lines="@(DisabledAnalyzers)" Overwrite="true"
+ Condition="'@(DisabledAnalyzers)' != '@(_DisabledAnalyzers)'"/>
+
+ <ItemGroup>
+ <AdditionalFiles Include="$(IntermediateOutputPath)/disabledAnalyzers.config"/>
+ <FileWrites Include="$(IntermediateOutputPath)/disabledAnalyzers.config"/>
+ </ItemGroup>
+ </Target>
+
+</Project>