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
.
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.
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).
Sorry for the late reply, and thanks for the input alan. Unfortunately your suggestion did not work so I ended up doing the following:
This build does not copy output files to a drop folder
under the Build defaults tabAsConfigured
as the value for the Output location
under 2. Build
under the Process tabUse this MSBuild argument string:
/p:DeployOnBuild=True;DeployTarget=PipelinePreDeployCopyAllFilesToOneFolder;PackageTempRootDir="\\192.168.xx\Nightly\MainBranch";AutoParameterizationWebConfigConnectionStrings=false
This result is the following folder which I use as the webroot for the test site: \\192.168.xx\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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.