How can i set BuildInParallel="false" in my .csproj?
In the following example, .csproj has two build targets for net6.0
and net8.0
. In default they are run in parallel build processes in Visual Studio Professional 2022 IDE build.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
</PropertyGroup>
<!-- it makes scripts.zip before build -->
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="call make_zip.bat" />
</Target>
<ItemGroup>
<Content Include=".\scripts.zip" CopyToOutputDirectory="Always" />
</ItemGroup>
</Project>
I have a PreBuild
action which makes a zip file from some scripts and python files. This final scripts.zip will be a content of the final build. Because in default, net6.0
and net8.0
are running in parallel build processes, make_zip.bat
try to run in parallel for each build but unfortunately it will crash all the time, because same files are busy and can not compressed them twice to a same output zip files in parrallel time.
I can solve this issue if i use dotnet
command line with -p:BuildInParallel=false
for building. But how can i force to use BuildInParallel=false
in my .csproj file in order to use it in Visual Studio Professional 2022 IDE also as a default settings?
Based on your description, I was able to successfully reproduce the problem you encountered:
If you want to set BuildInParallel="false" in .csproj, you only need to add <BuildInParallel>false</BuildInParallel>
: