Web Package: How to force MSBuild to use MSDeploy.IisApp instead of sitemanifest? - iis

How do I force MSBuild to create a Web Package that uses the iisApp Provider Application Path such as "Default Web Site/Catalog"?
My build process is creating a package that uses a directory path (C:\Agent\_work\28\s\Catalog).
I have tried to add the "/p:DeployAsIisApp=True" in my MSBuild command, but that doesn't seem to make a difference.
If I set the virtual directory to my Visual Studio 2017 solution folder, then Export a Package through IIS Manager, the package is created the way I'm expecting.
I compared the archive.xml files between MSBuild and the IIS Export. Here is some partial output:
MSBuild:
<sitemanifest MSDeploy.ObjectResolver.createApp= ...>
<iisApp path="C:\Agent\_work\28\s\Catalog ...>
...
</sitemanifest>
IIS Export:
<MSDeploy.IisApp MSDeploy.ObjectResolver.createApp= ...>
<iisApp path="Default Web Site/Catalog" ...>
...
</MSDeploy.IisApp />
So IIS is exporting MSDeploy.IisApp while MSBuild is creating a sitemanifest.
How do I get MSBuild to match the IIS Export? I'm using the VSTS build system and the parameters I'm passing to MSBuild are:
MSBuild /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:PackageLocation="$(build.artifactstagingdirectory)\Catalog" /p:IncludeSetAclProviderOnDestination=False

I solved the issue.
The specific issue I had been experiencing was a line in the logs that looked like this:
Verbose: Parameter entry 'IIS Web Application Name/1' could not be applied anywhere.
Parameters.xml was this (broken):
<parameters>
<parameter name="IIS Web Application Name"
description="Full site path where you want to install the Catalog Application (for example, Default Web Site/Catalog)."
defaultValue="Default Web Site/Catalog"
tags="IisApp">
<parameterEntry kind="ProviderPath" scope="iisApp" match="#defaultValue" />
</parameter>
I set the match attribute to an empty string. Then everything started working as expected. Working:
<parameters>
<parameter name="IIS Web Application Name"
description="Full site path where you want to install the Catalog Application (for example, Default Web Site/Catalog)."
defaultValue="Default Web Site/Catalog"
tags="IisApp">
<parameterEntry kind="ProviderPath" scope="iisApp" match="" />
</parameter>

Related

Deleting an application directory from iss with appcmd and reports identifer needed

I have somehow created an application directory with the appcmd command that has hidden all of my applications directory.
I can do a list of my application directories with appcmd and I think the last directory I created has the file path with a double quote character at the end, so I'm trying to delete that one application directory.
When I run the command appcmd list app I get the list of my application directories which do not show up in the UI.
Here is a list of the last three:
APP "Default Web Site/hotele/language90" (applicationPool:DefaultAppPool)
APP "Default Web Site/hotele/business900" (applicationPool:DefaultAppPool)
APP "Default Web Site/hotelk" (applicationPool:DefaultAppPool)
When I attempt to delete the hotelk one which is the one I think is messing up all of the directories I try running this command:
appcmd delete app "Default Web Site"/"hotelk"
It gives me this error:
message:Must use exact identifier for APP object with verb DELETE.
I've tried many different combinations of this delete syntax and not use what is meant by the identifier?
I can't delete this application directory with the IIS UI since when I go there all of my application directories do not appear.
First of all try to delete the app from Internet Information Services (IIS) Manager GUI.
If you can't find your app there you can manually edit IIS configuration file (ApplicationHost.config):
Go to path %windir%\system32\inetsrv\config
Create a backup of ApplicationHost.config file
Open ApplicationHost.config file
Search the name of the app you want to remove (ex. hotelk). You should find it in the <sites> section:
<sites>
<site name="Default Web Site" id="1">
...
</site>
<site name="hotelk"" id="2">
<application path="/">
<virtualDirectory path="/" physicalPath="d:\test" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:" />
</bindings>
</site>
<siteDefaults>
...
</siteDefaults>
<applicationDefaults applicationPool="DefaultAppPool" />
<virtualDirectoryDefaults allowSubDirConfig="true" />
</sites>
remove the entire node containing the site you want to delete
save the file
If you want delete the app using appcmd this is the right command:
appcmd delete app "Default Web Site/hotelk"

Web Deploy package throws ERROR_SITE_DOES_NOT_EXIST when deployed

After creating a WDP from an aspnet solution, the [project name].deploy.cmd file returns this error when executed:
Error Code: ERROR_SITE_DOES_NOT_EXIST
More Information: Site 'freedomstoreusa.azurewebsites.net' does not exist. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_SITE_DOES_NOT_EXIST.
Error count: 1.
My objective is to deploy the package to this site as if it were publishing to azure from visual studio 2017. What is causing this issue, what can resolve it and what are some alternatives to packaging and deploying a website?
Here are my settings in the package wizard:
what can resolve it and what are some alternatives to packaging and deploying a website?
I build and package the web application project, and use MSDeploy.exe to deploy the web application, which works fine on my side.
Command:
TestSite.SetParameters.xml
<?xml version="1.0" encoding="utf-8"?>
<parameters>
<setParameter name="IIS Web Application Name" value="{app name}" />
</parameters>
I came here with the same problem but the image in the question and the answer from Fei Han solve my problem I was creating a File System Package not a Web Deploy Package which will create App.SetParameters.xml and the App.zip in the selected folder it also will ask for the app name an then you can use that auto generated file for the param -setParamFile:

Web API configurations work in debug but not in iis

I'm making a Web API project and I'm using iis.
I made the project and then I needed to add bundling to it. I used system.web.optimization file and webgreas DLLs from the default MVC project that is created by visual studio. There was an error for the required version of the webgreas DLL and I had to add the following configurations to the web.config file and it all worked fine when debugging.
<runtime>
<assemblyBinding xmls="urn:schemas-microsoft-com:ASM.v1">
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="..." />
<bindingRedirect oldVersion="1.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
After publishing to iis the configurations I made just didn't allow the deployed server to run and the error pops up when you try to go to any path:
Directory does not exist
Parameter name: directory virtual path
My question is if runtime tag can or can't be used in iis and how to fix this and import the DLLs correctly. (Preferably without using nuget)

How to share parameters configuration between VS publish profile and MSDeploy SetParameters.xml?

I have a web application in Visual Studio 2012. I publish this website to IIS using publish profiles (.pubxml).
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>MSDeploy</WebPublishMethod>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<ExcludeApp_Data>False</ExcludeApp_Data>
<MSDeployServiceURL>server</MSDeployServiceURL>
<DeployIisAppPath>site</DeployIisAppPath>
<RemoteSitePhysicalPath />
<SkipExtraFilesOnServer>False</SkipExtraFilesOnServer>
<MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
<EnableMSDeployBackup>True</EnableMSDeployBackup>
<UserName>domain\username</UserName>
</PropertyGroup>
<ItemGroup>
<MSDeployParameterValue Include="MyParam">
<ParameterValue>MyValue</ParameterValue>
</MSDeployParameterValue>
...
</ItemGroup>
</Project>
Beside I setup a CI to build a package with msbuild and then use it to publish to the different environnement using msdeploy. Both in 2 separates steps, so I can reuse the same package multiple times.
To do this I need to use a SetParameters.xml with a different syntax than the publish profil used by VS.
<?xml version="1.0" encoding="utf-8"?>
<parameters>
<setParameter name="IIS Web Application Name" value="site" />
<setParameter name="MyParam" value="MyValue" />
...
</parameters>
Is there a way to share the parameters configuration in a single file so I can maintain only one file ?
I see this answers from 2014 but I can't managed to make it works.
I've researched this and can't find a way to override the SetParameters file when publish via VisualStudio. It doesn't look like the MSBuild tasks support this.
The best alternative I can offer is to use the commandline instead of right click publish. You can create the MSDeploy package by calling the Package target:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild /t:Package /p:PublishProfile=<profile-name>
And then deploy using MSDeploy.exe:
"C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync -source:package=WebApplication7.zip -dest:manifest=WebApplication7.DestManifest.xml -setParamFile:SetParameters.custom.xml
The following blog posts has more details:
https://dotnetcatch.com/2016/02/25/the-anatomy-of-a-webdeploy-package/

Convert folder under virtual directory to Application, using WIX

How can I convert a directory under a virtual directory to an application, using WIX?
WIX installs the following Virtual Directory to IIS, and I wish it to also convert the webservice folder to an application.
I could not find a way to do this through WIX or the IIS extension, so I resorted to calling an external command. For future reference, the commands are:
IIS 5
C:\Inetpub\AdminScripts\mkwebdir.vbs -c Localhost -w "Default Web Site" -v "sentry/webservice","{physical path}"
C:\Inetpub\AdminScripts\adsutil.vbs appcreateinproc w3svc/1/root/sentry/webservice
IIS 6
C:\Windows\System32\iisvdir.vbs /create "Default Web Site/Sentry/webservice" webservice "{physical path}"
IIS 7
C:\Windows\System32\inetsrv\appcmd add app /site.name:"Default Web Site" /path:/Sentry/webservice /physicalPath:"{physical path}"
This can be done with the IISExtension, as Daniel Morritt suggests. As it's very difficult to find sample code for this I thought I'd post how I did it.
<!-- Your example uses the default web site. -->
<iis:WebSite Id="DefaultWebSite" Description="Default Web Site" SiteId="*">
<iis:WebAddress Id="DefaultWebAddress" Port="80"/>
</iis:WebSite>
<!-- Web Dir Properties to enable access to a Web Application. -->
<iis:WebDirProperties Id="AnonymousExecuteAndScript"
Read="yes"
Write="no"
Execute="yes"
Script="yes"
AnonymousAccess="yes"
Index="no"
LogVisits="no"/>
<!-- Assumes the presence of this directory reference. -->
<DirectoryRef Id="SentryWebServiceDir">
<Component Id="SentryWebServiceComponent" Guid="{GUID-GOES-HERE}">
<iis:WebVirtualDir Id="SentryWebService"
DirProperties="AnonymousExecuteAndScript"
Alias="Sentry/webservice"
Directory="SentryWebServiceDir"
WebSite="DefaultWebSite">
<!-- Make this virtual directory a web application -->
<iis:WebApplication Id="SentryWebServiceApp" Name="webservice" WebAppPool="DefaultAppPool"/>
</iis:WebVirtualDir>
<!-- Workaround for the need for a KeyPath for this component. -->
<RegistryValue Root="HKLM"
Key="SOFTWARE\YourCompany\Sentry\WebService"
KeyPath="yes"
Value="1"
Type="binary"
Name="Installed"
Id="SentryWebServiceInstalled"/>
</Component>
</DirectoryRef>
All of the above can be nested in a <Fragment> element.
You can add a reference to the WiX IISExtension to your project and create one using this.
A good example of this can be found here: Using WiX to create an IIS virtual directory
I have tested this approach, and it works:
http://www.mail-archive.com/wix-users#lists.sourceforge.net/msg04374.html
It says to put the whole path in the Alias, for example
<iis:WebVirtualDir Id="VIRTDIR_Sentry_webservice"
Directory="WebService"
Alias="Sentry/webservice"
WebSite="SITE_Default"> ...

Resources