dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.65k stars 1.06k forks source link

Add MsDeploySkipRule support for web package deployment #12477

Open unkinected opened 6 years ago

unkinected commented 6 years ago

Per the latest (as of 12/20/2017) comments on this issue: https://github.com/aspnet/websdk/issues/239, msdeploy skip rules are not being honored during web package creation and deployment. The cmd file that is generated for the package does not include any skip rules specified per the documentation.

Can we please add support for this? This would make my life a whole simpler if I don't have to edit the cmd file myself manually after the package is created.

Thanks!

vijayrkn commented 6 years ago

The fix should happen here - https://github.com/aspnet/websdk/blob/4242b7c808ab0b87cb4e48ca79a44001e4e0f276/src/Publish/Microsoft.NET.Sdk.Publish.Targets/netstandard1.0/PublishTargets/Microsoft.NET.Sdk.Publish.MSDeployPackage.targets#L193

This should honor the MsDeploySkipRules https://github.com/aspnet/websdk/blob/4242b7c808ab0b87cb4e48ca79a44001e4e0f276/src/Publish/Microsoft.NET.Sdk.Publish.Targets/netstandard1.0/PublishTargets/Microsoft.NET.Sdk.Publish.MSDeployPackage.targets#L286

mrtristan commented 6 years ago

this keeps biting me. is this something that is still on the radar to be fixed?

kaiukdevelopment commented 6 years ago

This is something that we would really like too. This works perfectly in classic ASP.NET, but not for .NET Core. We'd rather not have to amend the .cmd file every time

stealth-grid commented 3 years ago

Any udates on this, Im still facing this issue. skip rules mentioned in .pubxml are not getting added to .deploy.cmd

Repro steps:

  1. create a new ASP.NET core WebAPI C# project.
  2. Add a publish profile like below
    <?xml version="1.0" encoding="utf-8"?>
    <!--
    This file is used by the publish/package process of your Web project. You can customize the behavior of this process
    by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121. 
    -->
    <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
    <WebPublishMethod>Package</WebPublishMethod>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish />
    <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
    <ExcludeApp_Data>False</ExcludeApp_Data>
    <ProjectGuid>7c382f5c-a447-4b79-96f4-174017110b71</ProjectGuid>
    <DesktopBuildPackageLocation>PublishOutput\WebApplication1.zip</DesktopBuildPackageLocation>
    <PackageAsSingleFile>true</PackageAsSingleFile>
    <DeployIisAppPath>Default Web Site/WebApp</DeployIisAppPath>
    </PropertyGroup>
    <ItemGroup>
    <MsDeploySkipRules Include="CustomSkipFolder">
      <ObjectName>filePath</ObjectName>
      <AbsolutePath>appsettings.json</AbsolutePath>
    </MsDeploySkipRules>
    </ItemGroup>
    </Project>
  3. Publish using command dotnet msbuild "WebApplication1.csproj" /nr:false /m /p:DeployOnBuild=true;PublishProfile=IISProfile
UriHendler commented 2 years ago

This has still not been fixed, as can be seen here:

https://github.com/dotnet/sdk/blob/main/src/WebSdk/Publish/Targets/PublishTargets/Microsoft.NET.Sdk.Publish.MSDeployPackage.targets#L84-L108

The MSDeploy target correctly passes the SkipRuleItems parameter to the MSDeploy/VSMSDeploy task, but the MSDeployPackage target does not.

@vijayrkn was there a clear rationale behind changing this behavior from the old ASP.Net behavior? If so, please enlighten me :wink:

Is there some workaround other than manually editing the Microsoft.NET.Sdk.Publish.MSDeployPackage.targets file?

As things stand, this is a big pain :disappointed:

niekvanderreest commented 2 years ago

After 2 very frustrating days trying to get this to work I too can confirm this is still an issue with Web Deploy Package format. Editing the Microsoft.NET.Sdk.Publish.MSDeployPackage.targets does not work either, the resulting .cmd file will still not load the -skip rules. This should just work and is really a major downfall for this product.

Am I missing a step in editing the .targets file?