Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use MsBuild MsDeployPublish to target local file system?

I'm trying to replicate the Visual Studio 2010 "Publish..." command (applicable to Web Application projects) where I would in the UI choose Publish Method: "File System".

My attempt at this is...

%msbuild% /t:MsDeployPublish /property:MsDeployServiceUrl="file:///d:\MyDeploymentFolder";MsDeployPublishMethod="File System" "d:\MySourceFolder\Project.csproj"

... and having tried a method of "FileSystem", "File System", "Local", and a few others.

The error I get implies that MsDeploy is still trying to push to an IIS server:

"D:\MySourceFolder\Project.csproj" (MsDeployPub lish target) (1) -> (MSDeployPublish target) ->   C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web .Publishing.targets(3847,5): error : Web deployment task failed.(The metabase k ey '/lm/w3svc' could not be found.) [D:\MySourceFolder\Project.csproj] C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.P ublishing.targets(3847,5): error : \r [D:\MySourceFolder\Project.csproj] C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.P ublishing.targets(3847,5): error : The metabase key '/lm/w3svc' could not be fo und.\r [D:\MySourceFolder\Project.csproj] C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.P ublishing.targets(3847,5): error : Unable to access the IIS configuration syste m. Please make sure you have IIS 7 (or later) installed.\r [D:\MySourceFolder\Project.csproj] C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.P ublishing.targets(3847,5): error : Retrieving the COM class factory for compone nt with CLSID {2B72133B-3F5B-4602-8952-803546CE3344} failed due to the followin g error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REG DB_E_CLASSNOTREG)). [D:\MySourceFolder\Project.csproj] 

How can I target the file system for deployment, as Visual Studio normally lets me in the GUI?

like image 615
DuckMaestro Avatar asked Feb 07 '12 00:02

DuckMaestro


People also ask

How do I create a Pubxml file?

In order to create a new profile once you have already defined one, you have to open the "Publish" window (righ click on the project), click on the "Profile" tab and select the <New...> option from the drop-down list; this will create a new pubxml file (see screenshot).

What is Publish profile in MSBuild?

The publish profiles created with Visual Studio can be used with MSBuild and Visual Studio. For instructions on publishing to Azure, see Publish an ASP.NET Core app to Azure with Visual Studio. The dotnet new mvc command produces a project file containing the following root-level <Project> element: XML Copy.

Where can I find Publish profile?

Publish profile files are named <profilename>. pubxml and are located in the PublishProfiles folder. The PublishProfiles folder is under Properties in a C# web application project, under My Project in a VB web application project, or under App_Data in a web site project. Each .


Video Answer


1 Answers

As per my answer from Using MSBuild, how do I build an MVC4 solution from the command line (applying Web.config transformations in the process) and output to a folder?

msbuild ProjectFile.csproj /p:Configuration=Release ^                            /p:Platform=AnyCPU ^                            /t:WebPublish ^                            /p:WebPublishMethod=FileSystem ^                            /p:DeleteExistingFiles=True ^                            /p:publishUrl=c:\output 

Or if you are building the solution file:

msbuild Solution.sln /p:Configuration=Release ^                       /p:DeployOnBuild=True ^                      /p:DeployDefaultTarget=WebPublish ^                      /p:WebPublishMethod=FileSystem ^                      /p:DeleteExistingFiles=True ^                      /p:publishUrl=c:\output 

You can also target the project via the solution using the /t:SolutionFolder/Project:Target syntax:

msbuild Solution.sln /t:SolutionFolder/ProjectFile:WebPublish ^                      /p:Configuration=Release ^                       /p:WebPublishMethod=FileSystem ^                      /p:DeleteExistingFiles=True ^                      /p:publishUrl=c:\output 
like image 87
Richard Szalay Avatar answered Sep 21 '22 04:09

Richard Szalay