Build and publish C# .NET Web App via command line
NickName:user1094786 Ask DateTime:2014-06-05T22:46:55

Build and publish C# .NET Web App via command line

I need to be able to generically and separately build and publish C# ASP.NET Web Applications. Ideally, I would like to use MSBuild to build the application, and if that succeeds, I would like to simply publish the site preferably solely with file copy.

Currently, I am able to build web application quite easily with MSBuild, but it is the publishing that is causing confusion. After the build, the binaries sit in the bin folder, but I am not sure what files to copy. What would be a good way to mimic the operations that VS's publish feature does, and still keeping everything generic?

Copyright Notice:Content Author:「user1094786」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/24063305/build-and-publish-c-sharp-net-web-app-via-command-line

Answers
TrevorBrooks 2014-06-05T15:16:12

You can invoke the Visual Studio web publish pipeline using the command line, check out this tutorial it shows you step by step how to do it: \n\nSpecifying the publish profile\n\nYou can specify the publish profile by name or by the full path to the .pubxml file, as shown in the following example:\n\nmsbuild C:\\ContosoUniversity\\ContosoUniversity.sln /p:DeployOnBuild=true /p:PublishProfile=C:\\ContosoUniversity\\ContosoUniversity\\Properties\\PublishProfiles\\Test.pubxml\n\n\nWeb publish methods supported for command-line publishing\n\nThree publish methods are supported for command line publishing:\n\n\nMSDeploy - Publish by using Web Deploy.\nPackage - Publish by creating a Web Deploy Package. You have to install the package separately from the MSBuild command that creates it.\nFileSystem - Publish by copying files to a specified folder.\n\n\nhttp://www.asp.net/mvc/tutorials/deployment/visual-studio-web-deployment/command-line-deployment",


More about “Build and publish C# .NET Web App via command line” related questions

TFS Online Build and publish

I try to make a simple build and publish on tfs online for my provider hosted sharepoint application. After some NuGet tasks I'm using "Visual Studio Build" Task and after that I try to publish it ...

Show Detail

Override publish folder (url) of publish profile during the build pipeline

We have one ASP.Net solution with several projects. each project have build.pubxml with unique folder path. For example: In project Test we have this line inside the build.pubxml: <publishUr...

Show Detail

Build succeeds, but publish fails

Up until two days ago, I was able to use Visual Studio 2010's "Publish Web" option by right clicking on my project and clicking the publish button on the context menu. Now when I try to do the same...

Show Detail

Build and publish C# .NET Web App via command line

I need to be able to generically and separately build and publish C# ASP.NET Web Applications. Ideally, I would like to use MSBuild to build the application, and if that succeeds, I would like to s...

Show Detail

Why do we build and publish as two steps when publish also builds?

Sorry if this is a stupid question, but why does the dockerfile include steps to build and publish when the publish also builds? The following Dockerfile is created in my web application: FROM

Show Detail

Why bother with dotnet build before dotnet publish?

Welp. This seems like the type of question where I'll facepalm seeing the answer. So... Why bother with dotnet build before doing a dotnet publish? build automatically does a restore. Cool. ...

Show Detail

ERROR [build 6/6] RUN dotnet publish "" -c Release -o /app/publish

I'm building an image for Web API .Net 5 My folder directory looks like this D:\Working\Phong_Nguyen_Super_Hero\Weather Forecast Application\WeatherForecast-main\TLY.WeatherForecast ...

Show Detail

How to build, package, and publish a C# exe application?

I am coming from the Java world into the C# world so I'm sorry if this question doesn't make sense. But, overall, what I'm trying to do is figure out how the C# world handles packaging and publishi...

Show Detail

How to build, package, and publish a C# exe application?

I am coming from the Java world into the C# world so I'm sorry if this question doesn't make sense. But, overall, what I'm trying to do is figure out how the C# world handles packaging and publishi...

Show Detail

Build and Publish (ASP.NET Web Application) using Microsoft.Build.Engine using c#

I want to Build a VS2008 project (ASP.NET Web Application) and then publish using Microsoft.Build.Engine. I have so far successfully managed to BUild the project. But i am unable to Publish it to a

Show Detail