.Net Core 2 WebApp publishing to iis from package

2019-08-02 19:22发布

问题:

Prerequisites I've done:

Created simple Web API Project by template "ASP.NET Core Web Application" ( selected ASP.NET NetCore 2.1 ). Created a Publish Profile with next config

<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<WebPublishMethod>Package</WebPublishMethod>
<PublishProvider>FileSystem</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<ProjectGuid>ca211ccb-1868-47d8-a6nd-c30347faa49e</ProjectGuid>
<DeleteExistingFiles>False</DeleteExistingFiles>
<PackageLocation>C:\Test\Publish\CoreWebApi.zip</PackageLocation>
<DeployIisAppPath>Default Web Site/WebEngine555</DeployIisAppPath>    
</PropertyGroup>
</Project>

that helps generate a zip package.

After Deploying this package to IIS, ( I've done it with the next command )

C:\Program Files (x86)\IIS\Microsoft Web Deploy V3>msdeploy.exe -verb:sync -source:package="C:\Test\Publish\CoreWebApi.zip" -dest:auto="C:\inetpub\wwwroot\WebEngine" 
  • (I'd like to change this -dest:auto with more specific Provider but seems that it works only with that provider and have no idea how to look, or change the manifest, to make a source package compatible with other Providers. )

It installs the package to "C:\inetpub\wwwroot" root (Default Web Site, with deleting all other content from it).

Is it possible on the step of MSBuild configuration via the .pubxml file point the installation path ( Virtual path ) not to the root folder but in Subfolder at least? I was able to do it by running

C:\Program Files (x86)\IIS\Microsoft Web Deploy V3>msdeploy.exe -verb:sync -source:package="C:\Test\Publish\CoreWebApi.zip" 
-dest:auto="Default Web Site/WebEngine" 
-setParam:name="IIS Web Application Name",
value="Default Web Site/WebEngine5"

Also here Msdeploy replace attribute find a good answer, but it works only for simple new Web API. When I try to do the same for existing project, it always uses the '..\obj\Release\netcoreapp2.1\PubTmp\Out\' folder as sync destination and not copy files to the IIS folder at all. And with params abouve it's just not copy anything

  • even with the params in .pubxml file:

    Default Web Site/MeWebApp Default Web Site/MeWebApp C:\inetpub\wwwroot\Test2 C:\inetpub\wwwroot\Test1

What is the parameter that should affect that? Some targets seems are ignored in a new pipeline. I did a lot of experiments, most useful links by my point were blog, sdk, official, but still could not find the way to pick the publishing folder on deploy.