How to use MsDeploy to deploy a sub-application within a website - visual-studio

I have a sub application underneath an IIS website, and I can deploy it using the publish wizard in Visual Studio no problem.
However, I'm automating our deployment from our build server so I prefer to use msdeploy.exe directly.
I can deploy the main website, but trying to deploy the sub application refuses to work.
This works (www.mymainwebsite.co.uk being the IIS website):
msdeploy.exe
-source:package='www.mymainwebsite.co.uk\obj\Test\Package\www.mymainwebsite.co.uk.zip'
-dest:auto,computerName='https://testweb1:8172/MsDeploy.axd?site=www.mymainwebsite.co.uk',userName='xxx',password='xxx',authtype='Basic',includeAcls='False'
-verb:sync -disableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension -setParamFile:"www.mymainwebsite.co.uk\obj\Test\Package\www.mymainwebsite.co.uk.SetParameters.xml"
-allowUntrustedInfo
This doesn't (SubApplication being the application path):
msdeploy.exe
-source:package='SubApplication\obj\Test\Package\SubApplication.zip'
-dest:auto,computerName='https://testweb1:8172/MsDeploy.axd?site=www.mymainwebsite.co.uk/SubApplication',userName='xxx',password='xxx',authtype='Basic',includeAcls='False'
-verb:sync -disableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension -setParamFile:"SubApplication\obj\Test\Package\SubApplication.SetParameters.xml"
-allowUntrustedInfo
The error is:
Error Code: ERROR_USER_UNAUTHORIZED
More Information: Connected to the remote computer ("testweb1") using the Web Management Service, but could not authorize. Make sure that you are using the correct user name and password, that the site you are connecting to exists, and that the credentials represent a user who has permissions to access the site. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_USER_UNAUTHORIZED.
Error: The remote server returned an error: (401) Unauthorized.
As I said, this works from the Visual Studio publish wizard, setting the Site/application property to www.mymainwebsite.co.uk/SubApplication, so I know it's not a permissions issue on the server.
Am I missing something in the msdeploy parameters?

I use the following on the command line to set the web application:
-setParam:name="IIS Web Application Name",value="www.mymainwebsite.co.uk/SubApplication"

In order to do a web deployment to sub-application of a main site, go to TFS, Deploy IIS App step, update the Override parameters to something like this
name="IIS Web Application Name",value="MainSite/SubApplication"
It should do the trick!!

Related

Visual Studio 2017 Web publishing fails if user is non-admin while the same user can be used for VS2015 web publishing on the same web server

I am trying to publish a ASP.NET Core Web project to IIS (remote server) using a non-admin account using Visual Studio 2017 and I have the following error on deploy:
Starting Web deployment task from source:
manifest(D:\Projects\Own\AspNetCore\CoreWithAngularTrial\CoreWithAngularTrialApi\obj\Debug\netcoreapp1.1\PubTmp\CoreWithAngularTrialApi.SourceManifest.xml)
to Destination: auto(). C:\Program Files (x86)\Microsoft Visual
Studio\2017\Community\MSBuild\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeploy.targets(134,5):
Error : Web deployment task failed. (Connected to the remote computer
("...") using the Web Management Service, but could
not authorize. Make sure that you are using the correct user name and
password, that the site you are connecting to exists, and that the
credentials represent a user who has permissions to access the site.
Learn more at:
http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_USER_UNAUTHORIZED.)
Make sure the site name, user name, and password are correct. If the
issue is not resolved, please contact your local or server
administrator. Error details: Connected to the remote computer
("...") using the Web Management Service, but could
not authorize. Make sure that you are using the correct user name and
password, that the site you are connecting to exists, and that the
credentials represent a user who has permissions to access the site.
Learn more at:
http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_USER_UNAUTHORIZED.
The remote server returned an error: (401) Unauthorized. Publish
failed to deploy.
I have the following configuration for deployment:
Publish method = Web deploy
Server = servername:8172/msdeploy.axd
Site name = Default Web Site/CoreWithAngularTestApi
User name = username
Password = ******
The exact same configuration works when publishing a different application (ASP.NET MVC 5) under the same Web site (Default Web Site), so publishing configuration appears to be correct on the remote server.
Making username a local administrator unblocks the publishing process in Visual Studio 2017.
Also, publishing configuration files (*.pubxml) are virtually identical.
Event viewer on remote server catches the following error:
IISWMSVC_AUTHORIZATION_SERVER_NOT_ALLOWED
Only Windows Administrators are allowed to connect using a server
connection. Other users should use the 'Connect To Site or
Application' task to be able to connect.
Process:WMSvc User=username
Question: How can I enabled non-administration web publishing from Visual Studio 2017?
This issue has been fixed: https://github.com/aspnet/websdk/issues/146.
ASP.NET core project uses a different set of Publish targets (hence the change in behavior from MVC5). This project is available on GitHub - https://github.com/aspnet/websdk.
I managed to figure out why the publish fails with non-admin user. Server setup is correct, but Visual Studio publishing seems to treat ASP.NET Core Web app deployment differently from ASP.NET MVC 5 one.
I had to explicitly specify web site name within the publishing profile xml file. So, instead of:
<MSDeployServiceURL>servername:8172/msdeploy.axd</MSDeployServiceURL>
I put
<MSDeployServiceURL>servername:8172/msdeploy.axd?Site=Default Web Site</MSDeployServiceURL>
NOTE: This problem does not occur when publishing an MVC 5 project within VS2017.

Cant web deploy web application from team city

Im having a bit of trouble web deploying from my CI server teamcity.I can however do a web deploy through visual studio.
I get the following error
Open in IDE
C:\Program Files
(x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.Web.Publishing.targets(4276,
5): error ERROR_DESTINATION_NOT_REACHABLE: Web deployment task failed.
(Could not connect to the remote computer ("destinationserver"). On
the remote computer, make sure that Web Deploy is installed and that
the required process ("Web Deployment Agent Service") is started.
Learn more at:
http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_DESTINATION_NOT_REACHABLE.)
and this is my configuration in team city
enter image description here
i have also opened up port 8172 so i dont think it is a permissions issue and checked the username and pass is correct
So what i dont understand is why i am able to publish locally but not from the CI?
Thanks,
Martin
I solve this replacing the IP address of the destination host with the DNS name and adding this parameter to the deployment:
/P:MsDeployServiceUrl=https://%TargetServer%/MsDeploy.axd?site=%SiteName%

Visual Studio webdeploy fail even when connection is validated?

I am trying to deploy my webapp VS2015 RC1 DNX 451. Even when I validate connection and run publish I get error
Severity Code Description Project File
Error Error Code: ERROR_USER_UNAUTHORIZED
Error More Information: Connected to the remote computer ("crocus.arvixe.com") using the Web Management Service, but could not authorize. Make sure that you are using the correct user name and password, that the site you are connecting to exists, and that the credentials represent a user who has permissions to access the site. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_USER_UNAUTHORIZED.
Error Error: The remote server returned an error: (401) Unauthorized.
Googling the issue and even trying to view host forum just says make sure username and password is correct. I am getting nowhere trying various settings. Any ideas how to debug the issue?
I am using Arvixe.com as host.
You should contact Arvixe.com. They likely have some odd configuration on their servers but I would suspect they can help you resolve the issue.
Arvixe does not support Web Deploy anymore. Once they move you to their new servers Web Deploy won't be available to you. In Visual Studio you can set up a Publish with FTP instead of Web Deploy. If you're used to Web Deploy publishing your database changes, then you'll need to do those yourself with SQL scripts. Entity Frameworks has an option to produce a SQL script for a migration, so you can use that to publish your EF database changes.

Building and starting a web role in Visual Studio with a specific URL

I have an Azure service containing a web role. Both configured to run on IIS Server locally. I would like to build/deploy and start the web role in a specific URL in Visual Studio. It always ends up in addresses using 127.0.0.1 even I specify what project URL is in the project configuration. Is there any way to change this something like dev.xxx.com?
You're running through the local emulator I assume. As such, the URL project settings won't apply. Just like if you deploy it to the cloud, you'll need some type of DNS forwarder or alias.

Visual Studio Web Package - doesn't appear to create full Application

I've got a .Net 4 ASP.Net application developed with VS 2012. I'm publishing the app with a publish profile set to create a Web Deploy Package, which I'll be copying over and creating on a Win2008 IIS7.3 server.
When I run the deployment script, server-side, with a "/Y" parameter, it appears to work correctly.
"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe"
-source:package='C:\ReconTool\test\deploy\ReconTool.Presentation.Web.zip"
-dest:auto,includeAcls="False" -verb:sync -disableLink:AppPoolExtension
-disableLink:ContentExtension -disableLink:CertificateExtension
-setParamFile:"C:\ReconTool\test\deploy\ReconTool.Presentation.Web.SetParameters.xml"
Info: Adding sitemanifest (sitemanifest).
Info: Creating application (Default Web Site/ReconToolTest)
Info: Adding virtual path (Default Web Site/ReconToolTest)
...
But the new web site doesn't run for me - I get an 403.18 - forbidden error. When I look in inetmgr on the server for the new app, I only see the 'IIS' config section, where applications I've created manually have an 'ASP.Net' and the 'IIS' config sections.
It appears like it's not creating a full application, there are no error pages, etc, that are configured in the ASP.Net section. Wierd thing is I see the new app via appcmd as an application:
APP "Default Web Site/" (applicationPool:DefaultAppPool)
APP "Default Web Site/ReconToolDev" (applicationPool:ReconToolDevPool)
APP "Default Web Site/ReconToolTest" (applicationPool:ReconToolTestPool )
Both the Dev and Test application pools appear to be exactly the same, from what I can tell. The web.config in my Dev and Test applications are identical.
I'd appreciate any advice on additional steps I need to deploy an Visual Studio project and get it to config as an application in IIS.
Corey.

Resources