How to run a clean build for a particular project from a solution in visual studio

前端 未结 4 1399
故里飘歌
故里飘歌 2020-12-24 05:22

Suppose I need to build a whole solution (which has multiple projects) in command line, is it possible to run a clean build for a particular projects and run an incremental

相关标签:
4条回答
  • 2020-12-24 05:24
    MSBuild.exe MultiProjectSolution.sln /t:"ProjectName:clean"
    

    Will clean only the specified project in your solution.

    0 讨论(0)
  • 2020-12-24 05:46

    Use msbuild and pass the Clean and Rebuild targets:

    msbuild path\to\solution\yoursolution.sln /t:Clean;Rebuild
    

    Or if you only want to rebuild a single project:

    msbuild path\to\project\yourproject.csproj /t:Clean;Rebuild
    

    msbuild is available in the Windows SDK or the Visual Studio Command prompt.

    0 讨论(0)
  • 2020-12-24 05:48

    Cleaning up specific projects:

    msbuild MyProjectFile1 /t:Clean
    msbuild MyProjectFile2 /t:Clean
    ...
    

    This has to be repeated for all projects you need to clean, because MSBuild only accepts single project on command line.

    Build whole solution incrementally:

    msbuild MySolutionFile
    

    Note, that this will build default configuration/platform for the projects and solution, which is often Debug/AnyCPU or Debug/Win32. If you want specific configuration/platform, you have to add parameters like this: /p:Configuration=Release /p:Platform=x64 to every msbuild command line.

    0 讨论(0)
  • 2020-12-24 05:51

    Just a small refinement for using in PowerShell:

    pathTo\MSBuild.exe pathTo\solutionfile.sln /target:"clean;Build"
    

    Source For Different Target

    0 讨论(0)
提交回复
热议问题