Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I publish a Asp.NET web application using MSBuild?

I am trying to publish an Asp.net MVC web application locally using the NAnt and MSBuild. This is what I am using for my NAnt target;

<target name="publish-artifacts-to-build">
    <msbuild project="my-solution.sln" target="Publish">
      <property name="Configuration" value="debug" />
      <property name="OutDir" value="builds\" />
      <arg line="/m:2 /tv:3.5" />
    </msbuild>
</target>

and all I get is this as a response;

[msbuild]          Skipping unpublishable project.

Is it possible to publish web applications via the command line in this way?

like image 731
Xian Avatar asked Sep 07 '08 16:09

Xian


People also ask

How do I publish an ASP NET project in Visual Studio?

This article supports ASP.NET and ASP.NET Core. You need Visual Studio installed with the ASP.NET and web development workload. Install the latest updates in Visual Studio by selecting Help > Check for Updates. Add the workload by selecting Tools > Get Tools and Features. In Solution Explorer, right-click your project and choose Publish.

How to use MSBuild (or DotNet) command to build and publish web applications?

How to use the MSBuild (or dotnet) command to build, publish, deploy ASP.NET web applications from the command line. msbuild WebApplication.csproj /p:DeployOnBuild=true /p:PublishUrl="C:\deployedApp ewapp" dotnet publish WebApplication.csproj /p:PublishDir="C:\deployedApp ewapp"

How do I deploy an ASP NET application from the command line?

Build, Publish and Deploy ASP.NET Web Applications from the Command Line How to use the MSBuild (or dotnet) command to build, publish, deploy ASP.NET web applications from the command line. msbuild WebApplication.csproj /p:DeployOnBuild=true /p:PublishUrl="C:\deployedApp ewapp"

Should I use multiple MSBuild publish scripts for deployment?

For smaller deployments this might be OK, but if you have multiple projects or you need to do some pre/post work (such as FTP or IIS related) you’re likely to want to put everything you need into a single MSBuild publish script so the deployment is repeatable, quicker and safer.


2 Answers

The "Publish" target you are trying to invoke is for "OneClick" deployment, not for publishing a website... This is why you are getting the seemingly bizarre message. You would want to use the AspNetCompiler task, rather than the MSBuild task. See http://msdn2.microsoft.com/en-us/library/ms164291.aspx for more info on this task. Your "PublishDir" would correspond to the TargetPath property of the task.

Source

like image 161
Espo Avatar answered Nov 01 '22 12:11

Espo


I came up with such solution, works great for me:

msbuild /t:ResolveReferences;_WPPCopyWebApplication /p:BuildingProject=true;OutDir=C:\Temp\buidl\ Test.csproj

Secret sauce is _WPPCopyWebApplication target.

like image 20
Alexander Beletsky Avatar answered Nov 01 '22 12:11

Alexander Beletsky