Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS2010 Web Publish command line version of File System deploy

Folks,

In a nutshell, I want to replicate this dialog: alt text

It's a Visual Studio 2010 ASP.Net MVC project. If I execute this command, I get all the files I want, including the transformed web.configs in the "C:\ToDeploy" directory.

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

I've seen various articles on how to do this on the command line for Remote Deploys, but I just want to do it for File System deploys.

I know I could replicate this functionality using nAnt tasks or rake scripts, but I want to do it using this mechanism so I'm not repeating myself.

I've investigated this some more, and I've found these links, but none of them solve it cleanly:

  • VS 2008 version, but no Web.Config transforms
  • Creates package, but doesn't deploy it..do I need to use MSDeploy on this package?
  • Deploys package after creating it above...does the UI really do this 2 step tango?

Thanks in advance!

like image 305
CubanX Avatar asked Oct 27 '10 02:10

CubanX


People also ask

How do I publish a Visual Studio solution from the command-line?

Basic command-line publishingThe default publish folder format is bin\Debug\{TARGET FRAMEWORK MONIKER}\publish\. For example, bin\Debug\netcoreapp2. 2\publish\. The dotnet publish command calls MSBuild, which invokes the Publish target.

How do I publish a web service in Visual Studio?

On the computer where you have the ASP.NET project open in Visual Studio, right-click the project in Solution Explorer, and choose Publish. If you have previously configured any publishing profiles, the Publish pane appears. Click New or Create new profile. Select the option to import a profile.


1 Answers

Ok, finally figured this out.

The command line you need is:

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

You can change where the project outputs to by adding a property of outdir=c:\wherever\ in the /p: section.

This will create the output at:

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

You can then copy those files from the above directory using whatever method you'd like.

I've got this all working as a ruby rake task using Albacore. I am trying to get it all done so I can actually put it as a contribution to the project. But if anyone wants the code before that, let me know.

Another wrinkle I found was that it was putting in Tokenized Parameters into the Web.config. If you don't need that feature, make sure you add:

/p:AutoParameterizationWebConfigConnectionStrings=false 
like image 105
CubanX Avatar answered Oct 12 '22 18:10

CubanX