VS2010 version Web Publish command line version for file system deployment

People,

In short, I want to repeat this dialogue: alt text

This is an MVC Visual Studio 2010 ASP.Net project. If I execute this command, I will get all the files that I want, including the converted web.configs in the "C: \ ToDeploy" directory.

I want to replicate this on the command line so that I can use it to build a QA environment.

I have seen various articles on how to do this on the command line for Remote Deploys, but I just want to do this to deploy the file system.

I know that I can replicate this functionality using nAnt tasks or graphical scripts, but I want to do this using this mechanism so that I don't repeat.

I explored this a few more, and I found these links, but none of them solved it cleanly:

Thanks in advance!

+45
command-line visual-studio-2010 msbuild-wpp msdeploy web-publishing
Oct 27 '10 at 2:24
source share
6 answers

Ok, finally figured it out.

Required command line:

msbuild path/to/your/webdirectory/YourWeb.csproj /p:Configuration=Debug;DeployOnBuild=True;PackageAsSingleFile=False 

You can change where the project is output by adding the outdir=c:\wherever\ property to the / p: section.

This will create an output using:

 path/to/your/webdirectory/obj/Debug/Package/PackageTmp/ 

Then you can copy these files from the above directory using any method you want.

Everything works for me as a ruby ​​rake task using Albacore . I am trying to do all this, so I can actually express it as a contribution to the project. But if anyone wants the code before then let me know.

Another wrinkle I discovered was that it put Tokenized Parameters in Web.config. If you do not need this feature, make sure you add:

 /p:AutoParameterizationWebConfigConnectionStrings=false 
+46
Oct 28 2018-10-28
source share

I thought I would post another solution that I found, I updated this solution to include the log file.

This is similar to Publish a web application from the command line , but just cleared and added the log file. also check the original source http://www.digitallycreated.net/Blog/59/locally-publishing-a-vs2010-asp.net-web-application-using-msbuild

Create MSBuild_publish_site.bat (specify it as you like) in the root project of your web application

 set msBuildDir=%WINDIR%\Microsoft.NET\Framework\v4.0.30319 set destPath=C:\Publish\MyWebBasedApp\ :: clear existing publish folder RD /S /Q "%destPath%" call %msBuildDir%\msbuild.exe MyWebBasedApp.csproj "/p:Configuration=Debug;PublishDestination=%destPath%;AutoParameterizationWebConfigConnectionStrings=False" /t:PublishToFileSystem /l:FileLogger,Microsoft.Build.Engine;logfile=Manual_MSBuild_Publish_LOG.log set msBuildDir= set destPath= 

Update the MyWebBasedApp.csproj web application project file by adding the following tag to the <Import Project=

 <Target Name="PublishToFileSystem" DependsOnTargets="PipelinePreDeployCopyAllFilesToOneFolder"> <Error Condition="'$(PublishDestination)'==''" Text="The PublishDestination property must be set to the intended publishing destination." /> <MakeDir Condition="!Exists($(PublishDestination))" Directories="$(PublishDestination)" /> <ItemGroup> <PublishFiles Include="$(_PackageTempDir)\**\*.*" /> </ItemGroup> <Copy SourceFiles="@(PublishFiles)" DestinationFiles="@(PublishFiles->'$(PublishDestination)\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="True" /> </Target> 

this works better for me than other solutions.

See the following information for more information:

1) http://www.digitallycreated.net/Blog/59/locally-publishing-a-vs2010-asp.net-web-application-using-msbuild

2) Publish a web application from the command line

3) Build a Visual Studio project through the command line

+11
Dec 20 '11 at 11:17
source share

My solution for CCNET with Web.config conversion:

 <tasks> <msbuild> <executable>C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe</executable> <workingDirectory>E:\VersionesCC\Trunk_4\SBatz\Gertakariak_Orokorrak\GertakariakMS\Web</workingDirectory> <projectFile>GertakariakMSWeb2.vbproj</projectFile> <targets>Build</targets> <timeout>600</timeout> <logger>C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MSBuild.dll</logger> <buildArgs> /noconsolelogger /p:Configuration=Release /v:diag /p:DeployOnBuild=true /p:AutoParameterizationWebConfigConnectionStrings=false /p:DeployTarget=Package /p:_PackageTempDir=E:\Aplicaciones\GertakariakMS2\Web </buildArgs> </msbuild> </tasks> 
+1
May 08 '13 at 8:36
source share

In VS2012 and above, you can reference existing publish profiles in your project with msbuild 12.0, this would be equivalent to right-clicking and publishing ... by selecting a publish profile ("MyProfile" in this example):

 msbuild C:\myproject\myproject.csproj "/P:DeployOnBuild=True;PublishProfile=MyProfile" 
+1
Sep 26 '14 at 19:58
source share

I have a solution for Visual Studio 2012: stack overflow

However, it works without installing Visual Studio at all! (see UPDATE ). I have not yet tested whether it is possible to get all the necessary materials from Visual Studio Express 2012 for a web installation.

0
Mar 15 '13 at 5:28
source share

Full CubanX Inspiration msbuild File

  <Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Target Name="Publish"> <RemoveDir Directories="..\build\Release\Web\" ContinueOnError="true" /> <MSBuild Projects="TheWebSite.csproj" Targets="ResolveReferences;_CopyWebApplication" Properties="Configuration=Release;WebProjectOutputDir=..\build\Release\Web;OutDir=..\build\Release\Web\bin\" /> </Target> <Target Name="Build" DependsOnTargets="Publish;"> </Target> </Project> 

This places the published website in the web directory .. \ build \ Release

-one
Sep 12 '12 at 11:31
source share



All Articles