-1

I am trying to publish an asp.net website through msbuild on command prompt, but I did not get success.

I tried by creating a new web application and execute below command, it works.

C:\Windows\system32>msbuild.exe "C:\VisualStudio 2012\Projects\HelloWorldSample\HelloWorldSample\HelloWorld\HelloWorldSample.csproj" /p:DeployOnBuild=true /p:PublishProfile="HelloDeploy"

But my problem is, in website I don't have .csproj file. That's why I am unable to execute above command for that.

So please any one help me how I can do deploy for a web site.

Thanks.

  • You will have .publishproj under App_Data folder. http://stackoverflow.com/questions/14819407/how-to-use-command-line-msbuild-to-deploy-vs2012-web-site-project-without-precom – gbs Oct 20 '14 at 04:12

1 Answers1

-1

If your website has no csproj project file it most likely is a directory containing just your website files. You can convert it to a Web Application (thus getting a csproj file) or directly use msdeploy to generate a deployable package and then use msdeploy to deploy it to your website. This is wat actually would happen under the hood when you run msbuild /p:DeployOnBuild

To create a msdeploy deployable website you can use the following snippet

msdeploy.exe 
  -verb:sync 
  -source:iisApp="C:\development\mywebsite\the-website-dir" 
  -dest:package="C:\temp\mywebsite-package.zip" 
  -declareParamFile:"C:\development\mywebsite\parameters.xml" 

You will need to create at a parameter for the site name in the parameters.xml file which will be packaged with the zipped website project

<?xml version="1.0" encoding="utf-8" ?>
<parameters>
<!-- 
This file contains (among others) references to web.config fields (xpath) 
which will be 'parameterized' on package before deploy. The actual values will then be filled in based on the given deploy environment.
-->
  <parameter name="IIS Web Application Name" tags="IisApp">
    <parameterEntry kind="ProviderPath" scope="iisApp" match="" tags="IisApp" />
  </parameter> 
</parameters>

This will generate a deployable msdeploy package which you can upload to your IIS by using:

msdeploy.exe -source:package=c:\temp\mywebsite-package.zip -dest:auto,computerName=https://mysite.example.com:8172/MsDeploy.axd,userName=USERNAME,password=PASSWORD,authtype=Basic, -verb:sync -disableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension -setParamFile:example-setParameters.xml -allowUntrusted

Together with a setParameter file

<?xml version="1.0" encoding="utf-8" ?>
<parameters>
  <setParameter name="IIS Web Application Name" value="mysite.example.com" />
</parameters>
Mark van Straten
  • 9,287
  • 3
  • 38
  • 57