Search code examples
msbuildinteractive

How do I work with MSBuild using the interactive switch


I am working on creating a custom .targets file for MSBuild Based compilation for my custom visual studio project.

I have been able to create a targets file which does the work of Build / Rebuild and Clean correctly.

However, I have a scenario where I need to provide some additional input during MSBuild Compilation. In the MSBuild command line reference, there are sections which talk about running MSBuild Interactively and with Response Files (.rsp).

Checking in the community here if someone has worked with making msbuild interactive or providing response through .rsp files.


Solution

  • For normal builds you shouldn't have to deal with interactive, it's used only for things like NuGet: https://github.com/dotnet/msbuild/pull/3697.

    Response files are text files with msbuild arguments which can be used instead of specifying them on the commandline: https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild-response-files

    So a my.rsp file containing

    # Comment in an response file.
    /p:x=y
    /t:mytarget
    

    and using msbuild foo.proj @my.rsp is equivalent to msbuild foo.proj /p:x=y /t:mytarget