How to invoke MSBuild via command prompt?
Solution 1
From your comment, your web project is a web site project and not a web application project.
In this case, 'Publish' target can not be the option but 'AspNetCompiler' is the solution.
Create an xml file with below content and call it from MSBuild.
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="PrecompileWeb">
<AspNetCompiler
VirtualPath="/MyWebSite"
PhysicalPath="c:\inetpub\wwwroot\MyWebSite\"
TargetPath="c:\precompiledweb\MyWebSite\"
Force="true"
Debug="true"
FixedNames="True"
/>
</Target>
</Project>
Reference to this task is here and you can configure all your un/check options.
FixedName="True" equals the checking of 'use fixed naming and single page...' option.
Then you call this file from MSBuild instead of the solution file.
MSBuild your.xml /p:Configuration=<Debug/Release>
As long as your class libraries are referenced by your web site project, they'll be built together.
Solution 2
MSBuild.exe **MYPROJ**.sln
/p:outdir="Z:\output\\",OutputPath="Z:\output\\",webprojectoutputdir="Z:\output\\",configuration=RELEASE
/t:Clean;Build
/flp1:logfile=Z:\output\\\Log_msbuild.log;verbosity=detailed
/flp2:logfile=Z:\output\\\Log_warnings.log;warningsonly;verbosity=detailed
/flp3:logfile=Z:\output\\\Log_errors.log;errorsonly;verbosity=detailed
/nologo
/noconlog
İt can compile all Types of projects(Web,webservice,desktop,..) and it can create log files as(buildlog,error and warnings).
Solution 3
Sorry for the late reply, and thanks for the input alan. Unfortunately your suggestion did not work so I ended up doing the following:
- Choose
This build does not copy output files to a drop folder
under the Build defaults tab - Use the default template under the Process tab
- Choose
AsConfigured
as the value for theOutput location
under2. Build
under the Process tab -
Use this MSBuild argument string:
/p:DeployOnBuild=True;DeployTarget=PipelinePreDeployCopyAllFilesToOneFolder;PackageTempRootDir="\\192.168.x.x\Nightly\MainBranch";AutoParameterizationWebConfigConnectionStrings=false
This result is the following folder which I use as the webroot for the test site: \\192.168.x.x\Nightly\MainBranch\PackageTmp
.
This obviously isn't optimal since I would prefer not to have the PackageTmp
folder and I also haven't tested what happens when there are multiple web applications in the same solution, but I can't use more time on this issue.
I really don't understand why Microsoft have made such a simple task so complicated.
Related videos on Youtube
Nasser Hadjloo
Founder @Sunkime, Former UX Manager @SimplyDesk, Speaker @TEDxTehran, Speaker @OWP1392, Sepaker @OWP1391, WindowsPhone nerd. UI / UX Designer who is into Localization, Globalization, Unicode and Web Standards ======================================= Website: http://wwww.hadjloo.ir Blog: http://Hadjloo.wordpress.com Twitter: @Hadjloo http://twitter.com/hadjloo
Updated on July 09, 2022Comments
-
Nasser Hadjloo almost 2 years
I have a website (not a web application) and I want to publish it from the command prompt in the same directory every night.
I don't want to use build automation tools like TeamCity, TFS, or third-party tools like Nant - it should be done with
MSBuild
. How can I do this?Update: in the Publish window the only option that should be checked is
Use Fixed naming and single page assemblies
.-
Nasser Hadjloo about 13 yearsit should be something like : msbuild Portal.sln or msbuild website
-
-
Nasser Hadjloo about 13 yearsMy Solution contains 4
class projects
and one website, I want to build the project first and then Publish the website. can you please write a psudo code for this senario? the only setting for publish is Use Fixed naming and single page assemblies and other checkboxes shouldn't be checked. Thank you in advance -
Nasser Hadjloo about 13 yearsYour answer is exatly what I'm looking for, but unfortunately when I run your command (MSBuild command) I face with an error,
This Application is already Precompiled
. what is it for. -
Nasser Hadjloo about 13 yearsmy problem resolved by removing PrecomciledWeb.Config from the path.