[Build] Add BuildWithAnalyzer property (#454)
authorWonYoung Choi <wy80.choi@samsung.com>
Wed, 5 Sep 2018 04:46:54 +0000 (13:46 +0900)
committerGitHub <noreply@github.com>
Wed, 5 Sep 2018 04:46:54 +0000 (13:46 +0900)
Add a property to enable NETCore.Analyzer.
Usages:
  ./build.sh build [module] /p:BuildWithAnalyzer=True
  ./build.sh full /p:BuildWithAnalyzer=True

build.sh
build/build.proj
build/common.props

index f94cc32..78119d8 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -32,8 +32,9 @@ cmd_build() {
   if [ -d /nuget ]; then
     NUGET_SOURCE_OPT="/p:RestoreSources=/nuget"
   fi
-  $RUN_BUILD /t:restore /p:Project=$1 $NUGET_SOURCE_OPT
-  $RUN_BUILD /t:build /p:Project=$1
+  PROJECT=$1; shift
+  $RUN_BUILD /t:restore /p:Project=$PROJECT $NUGET_SOURCE_OPT $@
+  $RUN_BUILD /t:build /p:Project=$PROJECT $@
 }
 
 cmd_full_build() {
@@ -41,8 +42,8 @@ cmd_full_build() {
     NUGET_SOURCE_OPT="/p:RestoreSources=/nuget"
   fi
   $RUN_BUILD /t:clean
-  $RUN_BUILD /t:restore $NUGET_SOURCE_OPT
-  $RUN_BUILD /t:build
+  $RUN_BUILD /t:restore $NUGET_SOURCE_OPT $@
+  $RUN_BUILD /t:build $@
 }
 
 cmd_dummy_build() {
index 35f4a16..6720119 100644 (file)
@@ -4,7 +4,8 @@
 
   <!-- Build Properties -->
   <PropertyGroup>
-    <Configuration>Release</Configuration>
+    <Configuration Condition="'$(Configuration)' == ''">Release</Configuration>
+    <BuildWithAnalyzer Condition="'$(BuildWithAnalyzer)' == ''">False</BuildWithAnalyzer>
   </PropertyGroup>
 
   <!-- Projects to build -->
@@ -50,7 +51,7 @@
   <Target Name="Restore">
 
     <MSBuild Projects="@(ProjectToBuild)"
-             Properties="Configuration=$(Configuration);RestoreSources=$(RestoreSources)"
+             Properties="Configuration=$(Configuration);RestoreSources=$(RestoreSources);BuildWithAnalyzer=$(BuildWithAnalyzer)"
              BuildInParallel="false"
              Targets="Restore" />
 
@@ -64,7 +65,7 @@
   <Target Name="Build">
 
     <MSBuild Projects="@(ProjectToBuild)"
-             Properties="Configuration=$(Configuration)"
+             Properties="Configuration=$(Configuration);BuildWithAnalyzer=$(BuildWithAnalyzer)"
              BuildInParallel="true"
              UseResultsCache="true"
              Targets="Rebuild" />
index 8476ad9..473a981 100644 (file)
 
   <Import Project="$(MSBuildThisFileDirectory)version.props" />
 
+  <ItemGroup Condition="'$(BuildWithAnalyzer)' == 'True'">
+    <PackageReference Include="Microsoft.NetCore.Analyzers" Version="2.6.1">
+      <PrivateAssets>all</PrivateAssets>
+      <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
+    </PackageReference>
+  </ItemGroup>
+
 </Project>