I'm an intern and have created an msbuild project that builds all of the .csproj files in the repository. Now I have to create a batch file that calls the msbuild.csproj I made and execute it on a daily schedule (say every day at 12:00pm). I don't know how to make a batch file and need some help getting started.
            Asked
            
        
        
            Active
            
        
            Viewed 9,726 times
        
    1 Answers
7
            Place this in a .bat file:
set msBuildDir=%WINDIR%\Microsoft.NET\Framework\v3.5    
REM perhaps you need a different framework? %WINDIR%\Microsoft.NET\Framework\v4.0.30319
call %msBuildDir%\msbuild /target:AllTargetsWrapper "MySolutionOrCsProj.sln" /p:Configuration=Debug;FavoriteFood=Twix /l:FileLogger,Microsoft.Build.Engine;logfile=ZZZZZMSBuildSetupAndBuildAllTargetsWrapper_Debug.log
set msBuildDir=
You'll have to adjust the target name.
Wait, I just remembered I answered this before in more detail. See:
        Community
        
- 1
 - 1
 
        granadaCoder
        
- 26,328
 - 10
 - 113
 - 146
 
- 
                    ooc why would he set msBuildDir 2x? it would be overwritten. Did you mean to put an IF EXIST in front? – rud3y Mar 13 '13 at 17:42
 - 
                    He (or she) didn't mention the framework he (or she) is using. You only need one "setter", but I was drawing attention that one has to match up the FW version. – granadaCoder Mar 13 '13 at 17:44
 - 
                    Ahh, If you change this to say IF EXIST %WINDIR%\.\.\v3.5 set msBuildDir= etc... do that first, that way it will use the latest version of .NETFW – rud3y Mar 13 '13 at 17:56
 - 
                    Just because one has the latest FW installed, does not mean that is the FW to use to build the .sln file. I have framework 4.5 installed, BUT, most of the time I am using FW 4.0 to build the projects. – granadaCoder Mar 13 '13 at 18:20
 - 
                    Ok, glad it helped. Don't forget you have the power to mark as "correct answer" and/or upvote the response. Thanks. – granadaCoder Mar 13 '13 at 19:04
 - 
                    @Beginners_Luck I agree, consider marking this as "Correct" if this has solved your answer – rud3y Mar 13 '13 at 20:26
 - 
                    @granadaCoder you are correct, however in this particular case wouldn't FW 3.5 be preferred over 2.0? – rud3y Mar 13 '13 at 20:27
 - 
                    Since 3.5 and 3.0 are more "add ons" to 2.0, yeah that might make sense. But building with \v4.0.30319\msbuild.exe simply because "it exists" (and you have a .sln/.csproj in VS2008 format).......isn't sound IMHO. – granadaCoder Mar 13 '13 at 20:41
 - 
                    I agree, but we didn't have /v4.0.30319 included :) – rud3y Mar 14 '13 at 21:02