Import .targets file from command line in msbuild

后端 未结 4 2154
野性不改
野性不改 2021-02-15 02:23

I currently have multiple projects being build using msbuild. I have a small customisation to the build that is handled by a .targets file. One solution is to add the snippet

4条回答
  •  失恋的感觉
    2021-02-15 03:01

    Make sure you use an absolute path to the target file and it works.
    Source: Sayed Ibrahim Hashimi - MSBuild how to execute a target after CoreCompile part 2.

    msbuild.exe /p:CustomBeforeMicrosoftCSharpTargets="c:\mytargets\custom.targets" /preprocess:out.xml
    

    Use /preprocess[:filepath] to see the result of the imports.

    You don't have to modify any csproj or vbproj files.
    Of course, it only works where you can set MSBuild Properties.

提交回复
热议问题