none
forcing a target to clean and rebuild using msbuild RRS feed

Answers

All replies

  • msbuild.exe SolutionName.sln /t:Clean,Build

     

    Monday, November 26, 2007 4:03 PM
  • Or alternatively /t:Rebuild - rebuild does exactly that, cleans and builds.

     

    Cheers, Eugene

     

    Wednesday, November 28, 2007 5:35 PM
  • Unfortunately, it has been my experience that msbuild /t:Rebuild does not do the expected clean operation before building.  I discovered this while doing an Intended Use Validation (IUV) for NCover 3.3.  I used a test application that was to be built and NCover tested with both VS2005 and VS2008.  One of the source files in the application had conditional compilation for three methods that used LINQ if it was built for VS2008, but not if it was built for VS2005.  The test scripts would first run the following sequence of batch files.

    1. cleanall.cmd           removed all compiler-generated output from folders
    2. rebuild2005.cmd     executed: c:\windows\microsoft.net\framework\v2.0.50727\msbuild app2005.sln /t:Rebuild /p:Configuration=Debug
    3. run NCover tests
    4. rebuild2008.cmd     executed: c:\windows\microsoft.net\framework\v3.5\msbuild app2008.sln /t:Rebuild /p:Configuration=Debug
    5. run NCover tests

    Because of the one source file that compiled differently between VS2005 and VS2008, we expected different NCover Symbol coverage results, but they were the same.  However, if we ran cleanall.cmd between steps 3 and 4, we got the expected results.

    It turns out that the DLL of which the conditionally-compiled source file was a part was put in an obj\Debug folder when built for VS2005, but when rebuild2008.cmd was run, that folder was not cleaned prior to building the VS2008 version of that source file, so the same VS2005 DLL was built into the VS2008 application, resulting in the same NCover results.

    It appears that the msbuild /t:Clean,Build option must be used to ensure that a clean is done prior to building.

     

    Tuesday, April 27, 2010 2:44 PM
  • That's odd as Rebuild depends on 

                BeforeRebuild;
                Clean;
                Build;
                AfterRebuild;


    Mike

    Visual Studio ALM MVP
    My Blog | MSBuild Extension Pack | MSBuild Explorer
    Tuesday, April 27, 2010 4:06 PM
    Moderator
  • Hi Nick,

    I had a similar experience.

    We used the devenv.exe solution.sln /clean.

    This will clean the solution prior to building.

    The reason was that somebody checked in some DLL's to the source control and when you just do a check out and then build. It gave the wrong result because of a missing clean.

    Tuesday, January 21, 2014 7:16 AM
  • msbuild.exe SolutionName.sln /t:Clean,Build

     

    The above doesn't work for me. This does though

    msbuild.exe SolutionName.sln /t:"Clean;Build"

    Wednesday, May 21, 2014 11:31 AM