Windows msbuild triggers too much to rebuild.
authorlateralusX <lateralusx.github@gmail.com>
Wed, 22 Mar 2017 10:52:42 +0000 (11:52 +0100)
committerlateralusX <lateralusx.github@gmail.com>
Wed, 22 Mar 2017 10:52:42 +0000 (11:52 +0100)
When building mono solution from Visual Studio it correctly handles incremental
builds just rebuilding what's needed. When doing the same from msbuild it rebuilds
to much. This happens due to two different issues.

First, a change in winconfig.h setting up a define for corlib version was not
included in our compare config file script, so diff was detected as a change in
config file causing a replace of config.h triggering a complete rebuild.

Second, once above was fixed there was still a rebuild of mini-amd64.c when not needed.
This was due to a difference in how post build events are handled in Visual Studio
and msbuild. Visual Studio will detect that the complete project won't need to be
rebuild and then it doesn't trigger any of the events. msbuild on the other hand
will trigger events even if nothing needs to be rebuild and that triggered creation of cpu-amd64.h
that in turn will trigger rebuild of mini-amd64.c. Switching from post build event
to a custom build step with proper input/output files will work as expected in both
Visual Studio and msbuild.

Commit also disables the build of test projects that are part of solution
but won't provide any build output. These projects are mainly there to make launching of test
configurations easier and doesn't need to be included in solution build.

msvc/compare-config-files.ps1
msvc/genmdesc.vcxproj
msvc/libmono-static.vcxproj
msvc/mono.sln

index 9122f1e8fc8dc7b3f892c9c95137cd1e33283453..72667c0324bda7141d510022212c68686255e3e0 100644 (file)
@@ -36,7 +36,8 @@ $comparedLines | foreach {
     {
                ##Look for diffs.
                $mono_version = (Select-String -InputObject $_.InputObject -pattern '#define VERSION \"(.*)\"')
-               if ($mono_version -eq $null) {
+               $mono_corlib_version = (Select-String -InputObject $_.InputObject -pattern '#define MONO_CORLIB_VERSION')
+               if ($mono_version -eq $null -And $mono_corlib_version -eq $null) {
                        Write-Host "Changes detected, versions doesn't match. Configuration must to be replaced."
                        exit 1;
                }
index 7183d6f4a80004ba495fc185e0ac61c284c27f57..b6a4a81c1357b523855f2c0290c6febb61513de3 100644 (file)
   </PropertyGroup>\r
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
     <LinkIncremental>true</LinkIncremental>\r
+    <CustomBuildAfterTargets>PostBuildEvent</CustomBuildAfterTargets>\r
   </PropertyGroup>\r
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
     <LinkIncremental>true</LinkIncremental>\r
+    <CustomBuildAfterTargets>PostBuildEvent</CustomBuildAfterTargets>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
+    <CustomBuildAfterTargets>PostBuildEvent</CustomBuildAfterTargets>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <CustomBuildAfterTargets>PostBuildEvent</CustomBuildAfterTargets>\r
   </PropertyGroup>\r
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
     <PreBuildEvent>\r
       <SubSystem>Console</SubSystem>\r
       <TargetMachine>MachineX86</TargetMachine>\r
     </Link>\r
-    <PostBuildEvent>\r
+    <PostBuildEvent />\r
+    <CustomBuildStep>\r
       <Command>runmdesc.bat "$(TargetPath)" $(Platform)</Command>\r
-    </PostBuildEvent>\r
+      <Message>genmdesc.exe Custom Build Step.</Message>\r
+      <Outputs>$(MONO_INCLUDE_DIR)\mini\cpu-x86.h</Outputs>\r
+      <Inputs>$(MONO_INCLUDE_DIR)\mini\cpu-x86.md</Inputs>\r
+    </CustomBuildStep>\r
   </ItemDefinitionGroup>\r
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
     <PreBuildEvent>\r
       <SubSystem>Console</SubSystem>\r
       <TargetMachine>MachineX64</TargetMachine>\r
     </Link>\r
-    <PostBuildEvent>\r
+    <PostBuildEvent />\r
+    <CustomBuildStep>\r
       <Command>runmdesc.bat "$(TargetPath)" $(Platform)</Command>\r
-    </PostBuildEvent>\r
+    </CustomBuildStep>\r
+    <CustomBuildStep>\r
+      <Message>genmdesc.exe Custom Build Step.</Message>\r
+    </CustomBuildStep>\r
+    <CustomBuildStep>\r
+      <Outputs>$(MONO_INCLUDE_DIR)\mini\cpu-amd64.h</Outputs>\r
+    </CustomBuildStep>\r
+    <CustomBuildStep>\r
+      <Inputs>$(MONO_INCLUDE_DIR)\mini\cpu-amd64.md</Inputs>\r
+    </CustomBuildStep>\r
   </ItemDefinitionGroup>\r
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
     <PreBuildEvent>\r
       <TargetMachine>MachineX86</TargetMachine>\r
       <GenerateDebugInformation>true</GenerateDebugInformation>\r
     </Link>\r
-    <PostBuildEvent>\r
+    <PostBuildEvent />\r
+    <CustomBuildStep>\r
       <Command>runmdesc.bat "$(TargetPath)" $(Platform)</Command>\r
-    </PostBuildEvent>\r
+      <Message>genmdesc.exe Custom Build Step.</Message>\r
+      <Outputs>$(MONO_INCLUDE_DIR)\mini\cpu-x86.h</Outputs>\r
+      <Inputs>$(MONO_INCLUDE_DIR)\mini\cpu-x86.md</Inputs>\r
+    </CustomBuildStep>\r
   </ItemDefinitionGroup>\r
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
     <PreBuildEvent>\r
       <TargetMachine>MachineX64</TargetMachine>\r
       <GenerateDebugInformation>true</GenerateDebugInformation>\r
     </Link>\r
-    <PostBuildEvent>\r
+    <PostBuildEvent />\r
+    <CustomBuildStep>\r
       <Command>runmdesc.bat "$(TargetPath)" $(Platform)</Command>\r
-    </PostBuildEvent>\r
+      <Outputs>$(MONO_INCLUDE_DIR)\mini\cpu-amd64.h</Outputs>\r
+      <Inputs>$(MONO_INCLUDE_DIR)\mini\cpu-amd64.md</Inputs>\r
+      <Message>genmdesc.exe Custom Build Step.</Message>\r
+    </CustomBuildStep>\r
   </ItemDefinitionGroup>\r
   <ItemGroup>\r
     <ClCompile Include="..\mono\mini\genmdesc.c">\r
index 18885f2304927357ed14d9e01da4ac3971f25cd4..a93798e286de6d338a0e9b8140a987bac13823f5 100644 (file)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>\r
+<?xml version="1.0" encoding="utf-8"?>\r
 <Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
   <ItemGroup Label="ProjectConfigurations">\r
     <ProjectConfiguration Include="Debug|Win32">\r
     <Link>\r
       <SubSystem>Windows</SubSystem>\r
     </Link>\r
-    <PostBuildEvent>\r
-      <Command>.\libmono.bat "$(MONO_INCLUDE_DIR)" "$(SolutionDir)include\mono" -q</Command>\r
-    </PostBuildEvent>\r
+    <PostBuildEvent />\r
   </ItemDefinitionGroup>\r
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
     <PreBuildEvent>\r
     <Link>\r
       <SubSystem>Windows</SubSystem>\r
     </Link>\r
-    <PostBuildEvent>\r
-      <Command>.\libmono.bat "$(MONO_INCLUDE_DIR)" "$(SolutionDir)include\mono" -q</Command>\r
-    </PostBuildEvent>\r
+    <PostBuildEvent />\r
   </ItemDefinitionGroup>\r
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
     <PreBuildEvent>\r
       <EnableCOMDATFolding>true</EnableCOMDATFolding>\r
       <OptimizeReferences>true</OptimizeReferences>\r
     </Link>\r
-    <PostBuildEvent>\r
-      <Command>.\libmono.bat "$(MONO_INCLUDE_DIR)" "$(SolutionDir)include\mono" -q</Command>\r
-    </PostBuildEvent>\r
+    <PostBuildEvent />\r
   </ItemDefinitionGroup>\r
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
     <PreBuildEvent>\r
       <EnableCOMDATFolding>true</EnableCOMDATFolding>\r
       <OptimizeReferences>true</OptimizeReferences>\r
     </Link>\r
-    <PostBuildEvent>\r
-      <Command>.\libmono.bat "$(MONO_INCLUDE_DIR)" "$(SolutionDir)include\mono" -q</Command>\r
-    </PostBuildEvent>\r
+    <PostBuildEvent />\r
   </ItemDefinitionGroup>\r
   <ItemGroup>\r
     <CustomBuildStep Include="..\mono\mini\mini-x86.h">\r
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\r
   <ImportGroup Label="ExtensionTargets">\r
   </ImportGroup>\r
-</Project>\r
+</Project>
\ No newline at end of file
index 193213c809b05a5c69ade222b03689eba06ad0a9..4a8ecd3326e2a094e6fad1b47285b8ff37476af3 100644 (file)
@@ -387,13 +387,9 @@ Global
                {C36612BD-22D3-4B95-85E2-7FDC4FC5D740}.Release|x64.ActiveCfg = Release|x64\r
                {C36612BD-22D3-4B95-85E2-7FDC4FC5D740}.Release|x64.Build.0 = Release|x64\r
                {3E0D229E-C39F-4EDA-9A6A-A33ECEA0322D}.Debug|Win32.ActiveCfg = Debug|Win32\r
-               {3E0D229E-C39F-4EDA-9A6A-A33ECEA0322D}.Debug|Win32.Build.0 = Debug|Win32\r
                {3E0D229E-C39F-4EDA-9A6A-A33ECEA0322D}.Debug|x64.ActiveCfg = Debug|x64\r
-               {3E0D229E-C39F-4EDA-9A6A-A33ECEA0322D}.Debug|x64.Build.0 = Debug|x64\r
                {3E0D229E-C39F-4EDA-9A6A-A33ECEA0322D}.Release|Win32.ActiveCfg = Release|Win32\r
-               {3E0D229E-C39F-4EDA-9A6A-A33ECEA0322D}.Release|Win32.Build.0 = Release|Win32\r
                {3E0D229E-C39F-4EDA-9A6A-A33ECEA0322D}.Release|x64.ActiveCfg = Release|x64\r
-               {3E0D229E-C39F-4EDA-9A6A-A33ECEA0322D}.Release|x64.Build.0 = Release|x64\r
                {CB0D9E92-293C-439C-9AC7-C5F59B6E0772}.Debug|Win32.ActiveCfg = Debug|Win32\r
                {CB0D9E92-293C-439C-9AC7-C5F59B6E0772}.Debug|Win32.Build.0 = Debug|Win32\r
                {CB0D9E92-293C-439C-9AC7-C5F59B6E0772}.Debug|x64.ActiveCfg = Debug|x64\r
@@ -403,37 +399,21 @@ Global
                {CB0D9E92-293C-439C-9AC7-C5F59B6E0772}.Release|x64.ActiveCfg = Release|x64\r
                {CB0D9E92-293C-439C-9AC7-C5F59B6E0772}.Release|x64.Build.0 = Release|x64\r
                {C7D83158-4EB6-4409-8730-612AD45FAF6A}.Debug|Win32.ActiveCfg = Debug|Win32\r
-               {C7D83158-4EB6-4409-8730-612AD45FAF6A}.Debug|Win32.Build.0 = Debug|Win32\r
                {C7D83158-4EB6-4409-8730-612AD45FAF6A}.Debug|x64.ActiveCfg = Debug|x64\r
-               {C7D83158-4EB6-4409-8730-612AD45FAF6A}.Debug|x64.Build.0 = Debug|x64\r
                {C7D83158-4EB6-4409-8730-612AD45FAF6A}.Release|Win32.ActiveCfg = Release|Win32\r
-               {C7D83158-4EB6-4409-8730-612AD45FAF6A}.Release|Win32.Build.0 = Release|Win32\r
                {C7D83158-4EB6-4409-8730-612AD45FAF6A}.Release|x64.ActiveCfg = Release|x64\r
-               {C7D83158-4EB6-4409-8730-612AD45FAF6A}.Release|x64.Build.0 = Release|x64\r
                {6C64262B-077B-4E12-AF91-9409ECCB75F6}.Debug|Win32.ActiveCfg = Debug|Win32\r
-               {6C64262B-077B-4E12-AF91-9409ECCB75F6}.Debug|Win32.Build.0 = Debug|Win32\r
                {6C64262B-077B-4E12-AF91-9409ECCB75F6}.Debug|x64.ActiveCfg = Debug|x64\r
-               {6C64262B-077B-4E12-AF91-9409ECCB75F6}.Debug|x64.Build.0 = Debug|x64\r
                {6C64262B-077B-4E12-AF91-9409ECCB75F6}.Release|Win32.ActiveCfg = Release|Win32\r
-               {6C64262B-077B-4E12-AF91-9409ECCB75F6}.Release|Win32.Build.0 = Release|Win32\r
                {6C64262B-077B-4E12-AF91-9409ECCB75F6}.Release|x64.ActiveCfg = Release|x64\r
-               {6C64262B-077B-4E12-AF91-9409ECCB75F6}.Release|x64.Build.0 = Release|x64\r
                {7BECCFA0-28A0-4995-9856-558560F720E6}.Debug|Win32.ActiveCfg = Debug|Win32\r
-               {7BECCFA0-28A0-4995-9856-558560F720E6}.Debug|Win32.Build.0 = Debug|Win32\r
                {7BECCFA0-28A0-4995-9856-558560F720E6}.Debug|x64.ActiveCfg = Debug|x64\r
-               {7BECCFA0-28A0-4995-9856-558560F720E6}.Debug|x64.Build.0 = Debug|x64\r
                {7BECCFA0-28A0-4995-9856-558560F720E6}.Release|Win32.ActiveCfg = Release|Win32\r
-               {7BECCFA0-28A0-4995-9856-558560F720E6}.Release|Win32.Build.0 = Release|Win32\r
                {7BECCFA0-28A0-4995-9856-558560F720E6}.Release|x64.ActiveCfg = Release|x64\r
-               {7BECCFA0-28A0-4995-9856-558560F720E6}.Release|x64.Build.0 = Release|x64\r
                {0046B994-40A8-4C64-AC9D-429DC9177B54}.Debug|Win32.ActiveCfg = Debug|Win32\r
-               {0046B994-40A8-4C64-AC9D-429DC9177B54}.Debug|Win32.Build.0 = Debug|Win32\r
                {0046B994-40A8-4C64-AC9D-429DC9177B54}.Debug|x64.ActiveCfg = Debug|x64\r
-               {0046B994-40A8-4C64-AC9D-429DC9177B54}.Debug|x64.Build.0 = Debug|x64\r
                {0046B994-40A8-4C64-AC9D-429DC9177B54}.Release|Win32.ActiveCfg = Release|Win32\r
-               {0046B994-40A8-4C64-AC9D-429DC9177B54}.Release|Win32.Build.0 = Release|Win32\r
                {0046B994-40A8-4C64-AC9D-429DC9177B54}.Release|x64.ActiveCfg = Release|x64\r
-               {0046B994-40A8-4C64-AC9D-429DC9177B54}.Release|x64.Build.0 = Release|x64\r
                {DC50997D-8A0D-4EB6-849B-9D7FBC39CE53}.Debug|Win32.ActiveCfg = Debug|x64\r
                {DC50997D-8A0D-4EB6-849B-9D7FBC39CE53}.Debug|x64.ActiveCfg = Debug|x64\r
                {DC50997D-8A0D-4EB6-849B-9D7FBC39CE53}.Debug|x64.Build.0 = Debug|x64\r
@@ -479,9 +459,9 @@ Global
                {DC50997D-8A0D-4EB6-849B-9D7FBC39CE53} = {DE3617B4-17A8-4E5F-A00F-BA43D956881F}\r
        EndGlobalSection\r
        GlobalSection(ExtensibilityGlobals) = postSolution\r
-               AMDCaProjectFile = C:\Users\Owner\Development\monogit\mono\msvc\CodeAnalyst\mono.caw\r
-               AMDCaPersistentStartup = mono\r
                AMDCaPersistentConfig = Debug|Win32\r
+               AMDCaPersistentStartup = mono\r
+               AMDCaProjectFile = C:\Users\Owner\Development\monogit\mono\msvc\CodeAnalyst\mono.caw\r
        EndGlobalSection\r
        GlobalSection(DPCodeReviewSolutionGUID) = preSolution\r
                DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000}\r