-
Notifications
You must be signed in to change notification settings - Fork 5
/
Directory.Build.targets
91 lines (82 loc) · 4.37 KB
/
Directory.Build.targets
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<Project>
<!--
IDEALLY THIS IS ALWAYS ENABLED, BUT THAT TENDS TO HURT DEVELOPER PRODUCTIVITY
=============================================================================
<PropertyGroup Condition="'$(BuildingInsideVisualStudio)' != 'true'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
-->
<!-- Analyzers-related configuration -->
<PropertyGroup>
<RunAnalyzersDuringLiveAnalysis>true</RunAnalyzersDuringLiveAnalysis>
<SolutionDir Condition="'$(SolutionDir)'==''">$(MSBuildThisFileDirectory)</SolutionDir>
<CodeAnalysisRuleSet>$(SolutionDir)\CodeAnalysis.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup>
<IsTestProject Condition="'$(IsTestProject)' == ''">$(MSBuildProjectName.Contains('.Test'))</IsTestProject>
</PropertyGroup>
<!-- StyleCop Analyzer-related configuration -->
<PropertyGroup Condition="Exists('$(SolutionDir)\CodeAnalysis.ruleset') And '$(BuildingInsideVisualStudio)' == 'true'">
<StyleCopTreatErrorsAsWarnings>True</StyleCopTreatErrorsAsWarnings>
</PropertyGroup>
<ItemGroup Condition="Exists('$(SolutionDir)\stylecop.json') And '$(BuildingInsideVisualStudio)' == 'true'">
<AdditionalFiles Include="$(SolutionDir)\stylecop.json" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.*">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<None Remove="**\*.Cache" />
</ItemGroup>
<!-- FxCop Analyzer-related configuration -->
<ItemGroup Condition="'$(BuildingInsideVisualStudio)' == 'true'">
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.*">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<!-- CodeCracker Analyzer-related configuration -->
<ItemGroup Condition="'$(BuildingInsideVisualStudio)' == 'true'">
<PackageReference Include="codecracker.CSharp" Version="1.1.*">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<!-- Sonar Analyzer-related configuration -->
<ItemGroup Condition="'$(BuildingInsideVisualStudio)' == 'true'">
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.0.*">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
<!-- Code Analyzers for projects using xUnit.net that help find and fix frequent issues when writing tests -->
<ItemGroup Condition="'$(BuildingInsideVisualStudio)' == 'true' And '$(IsTestProject)' == 'true'">
<PackageReference Include="xunit.analyzers" Version="1.1.*">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
<PropertyGroup>
<MSBuildTaskDllPath Condition="'$(MSBuildRuntimeType)' == 'Full'">$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll</MSBuildTaskDllPath>
<MSBuildTaskDllPath Condition="'$(MSBuildRuntimeType)' == 'Core'">$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll</MSBuildTaskDllPath>
<MSBuildTaskFactory Condition="'$(MSBuildRuntimeType)' == 'Full'">CodeTaskFactory</MSBuildTaskFactory>
<MSBuildTaskFactory Condition="'$(MSBuildRuntimeType)' == 'Core'">RoslynCodeTaskFactory</MSBuildTaskFactory>
</PropertyGroup>
<UsingTask TaskName="ReplaceFileText" TaskFactory="$(MSBuildTaskFactory)" AssemblyFile="$(MSBuildTaskDllPath)">
<ParameterGroup>
<InputFilename ParameterType="System.String" Required="true" />
<OutputFilename ParameterType="System.String" Required="true" />
<MatchExpression ParameterType="System.String" Required="true" />
<ReplacementText ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Using Namespace="System" />
<Using Namespace="System.IO" />
<Using Namespace="System.Text.RegularExpressions" />
<Code Type="Fragment" Language="cs">
<![CDATA[
File.WriteAllText(OutputFilename,Regex.Replace(File.ReadAllText(InputFilename),MatchExpression,ReplacementText));
]]>
</Code>
</Task>
</UsingTask>
</Project>