msbuild - incremental build for .dll

161 views Asked by At

Team develops C++ Utils project using the Visual Studio 2022. I have read about incremental builds: https://learn.microsoft.com/en-us/visualstudio/msbuild/how-to-build-incrementally?view=vs-2022 https://learn.microsoft.com/en-us/visualstudio/msbuild/incremental-builds?view=vs-2022

I am running msbuild and output of the build is Utils.dll file. That works fine, but if we re-run msbuild command currently .dll is overridden. So that is why I want to implement increment build so in case source files are changed only in that case .dll should be re-generated.

My simplified folder structure looks like this:

base/Utils
base/Utils/Atomic.cpp
base/Utils/x64/Release/Utils.dll

In that regards, I have defined Target segment to implement increment builds.

<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <ItemGroup>
            <CppFiles Include="Atomic.cpp"/>
            <DllFiles Include="x64\Release\Utils.dll"/>
      </ItemGroup>
      <Target Name = "Build"
            Inputs="@(CppFiles)"
            Outputs="@(DllFiles)">
      </Target>
</Project>

In this case, skipping works (if nothing is changed in Source file .dll file remains the same and it is not overwritten). That is good.

But if I change source .cpp file, unfortunately .dll is not incremented and re-built, but the older version remains (.dll file is not changed) What I am missing in the configuration?

Thanks a lot!!!

msbuild references my Utils.vcxproj, and we run msbuild from the level of the CI tool (not from IDE).

0

There are 0 answers