Import .targets file from command line in msbuild

后端 未结 4 1678
心在旅途
心在旅途 2021-02-15 02:44

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:06

    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.

提交回复
热议问题