2

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.

1 Answer 1

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:

Build Visual Studio project through the command line

Sign up to request clarification or add additional context in comments.

9 Comments

ooc why would he set msBuildDir 2x? it would be overwritten. Did you mean to put an IF EXIST in front?
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.
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
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.
Ok, glad it helped. Don't forget you have the power to mark as "correct answer" and/or upvote the response. Thanks.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.