MSdeploy Deploys MVC 2 Application with Invalid Virtual Directory Name

I use MSbuild (v4.0.30319.1) and MSdeploy (v7.1.618.0) to deploy my ASP MVC 2 application to IIS (v7.5). Here are the commands I ran for this:

msbuild.exe <path to my csproj>/MyMvcApp.csproj /t:Package /p:configuration=release;outDir=<my output dir> 

and msdeploy:

 msdeploy.exe -verb:sync -source:package='<MSBuildOutputDir>\_PublishedWebsites\Webui_Package\MyMVCApp.zip' -dest:auto 

After assembly and deployment, the application is deployed at http://localhost/MyMVCApp_deploy , and not at http://localhost/MyMVCApp . I did not expect _deploy be in the address. How can i fix this?

+4
asp.net-mvc iis msbuild msdeploy
source share
2 answers

As the portal noted, you can control the application name on the properties page. I will talk a little about this answer.

Set default value on PP / Web tab

By default, when you package / publish your web project, we will create a Web Deploy parameter named IIS Web Application Name that controls this value. The default value for this is ProjectName_deploy . The reason we add the _deploy suffix for IIS scripts. You may already have an IIS application named ProjectName , but it is much less likely that you will have one ProjectName_deploy name. You can configure this value on the Package / Publish Web tab of the project properties. One thing to keep in mind if you are following this route is that all of these options are tied to a configuration configuration. . Therefore, if you configure the settings in Debug and create your package using Release, these settings will not apply. See image below.

enter image description here

When you set this value, it sets the MSBuild property, DeployIisAppPath, and you can use it if you want to have some logic associated with the resulting value.

Pass the parameter value in the publication

If you want, you can also simply specify the value of this parameter when publishing. Here you have two main approaches.

  • Specify a value for an individual property
  • Specify a value for this and other properties in the file

1. Specify a value for an individual property:

You can use the -setParam parameter when calling msdeploy.exe to give a new value for this parameter. For example:

 %msdeploy% -verb:sync -source:package=WebApplication3.zip -dest:auto -setParam:name="IIS Web Application Name",value="Default Web Site/FooBar" 

2. Specify a value for this and other properties in the file

When you create a package in VS, we automatically create a file for you called {ProjectName} .SetParameters.xml. This file is a simple XML file and it will contain all the parameters along with the default values. You can update this file to include the correct parameter values, and then transfer it to the msdeploy.exe file (note: you do not need to name the file ... SetParameters.xml you can rename it at any convenient for you). If you want to use this approach, just use the -setParamFile option when calling msdeploy.exe. The following is an example of command line syntax for this:

 %msdeploy% -verb:sync -source:package=WebApplication3.zip -dest:auto -setParamFile=WebApplication3.SetParameters.xml 
+12
source share

Change the application name in the settings.

Right-click web project properties. Go to the package / publish the website, change the name of the application that will be used on the deactivation server, from "default website / mymvcapp _deploy" to "default website / mymvcapp"

+2
source share

All Articles