question

Francois-0718 avatar image
0 Votes"
Francois-0718 asked Francois-0718 answered

MSBuild launch multiple times on PostBuildEvent when compiling with -maxcpucount

When I try to compile my big solution (100 projects) with MSBuild, I have an error with PostBuildEvent.
I have a very base project where most of other project add depend on. In this project, I have a simple PostBuildEvent which modify the Dll file by adding a "custom signature".

When I run MSBuild with parallel option -maxcpucount, in have this error.

  18>PostBuildEvent:
      Impossible to open : D:\BuildAgent9\work\b63dd3bbf6a8743c\exe\Debug_x64\DllToSigned.dll
    
  18>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(153,5): error MSB3073: The command ""D:\BuildAgent9\work\b63dd3bbf6a8743c\CreateSignature.exe" "D:\BuildAgent9\work\b63dd3bbf6a8743c\exe\Debug_x64\DllToSigned.dll"
 C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(153,5): error MSB3073:
 C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(153,5): error MSB3073: :VCEnd" exited with code 1.

My tool, "CreateSignature.exe" print error "Impossible to open : ...", because the file is already open.

The project has already been linked and finished.

Checking in the MSBuild log file, this PostBuildEvent is call about 40 times (for 100 projects to compile). Other project which has a dependency on it, seem to re-ask to execute the PostBuildEvent. Which lead to problem because only one could open the dll file in write access...

Of course, I really need to compile in Parallel, else it takes twice the time to compile the solution.
How to modify the vcxprj in order to have this PostBuildEvent execute only once.

Note that I used the project reference for dependencies between project. Like this:

 <ProjectReference Include="..\..\DllToSigned.vcxproj">
   <Project>{...}</Project>
   <Private>false</Private>
   <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
   <LinkLibraryDependencies>false</LinkLibraryDependencies>
 </ProjectReference>


vs-msbuild
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

DylanZhu-MSFT avatar image
0 Votes"
DylanZhu-MSFT answered

Hi Francois,

It seems that there are some problems about msbuild tool. We suggest you report it in developer community: https://developercommunity.visualstudio.com/report?space=8&entry=problem

Best Regards,
Dylan


If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Francois-0718 avatar image
0 Votes"
Francois-0718 answered
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.