【问题标题】:MsDeploySkipRules being ignored on project publish项目发布时忽略 MsDeploySkipRules
【发布时间】:2021-01-22 21:54:59
【问题描述】:

我想将wwwroot\data 中的所有文件和文件夹排除在我的网站文件夹中。我网站文件夹中的文件是最新的副本,在我发布项目时绝不应该被覆盖。

Reference Microsoft documentation

文档表明在 .csproj 文件中使用此 xml,但我无法使其正常工作。我试过把它放在我的.csproj 文件和.pubxml 中,但没有成功。

我做错了什么?有人能告诉我这是否真的有效吗?

   <ItemGroup>
    <MsDeploySkipRules Include="CustomSkipFolder">
      <ObjectName>dirPath</ObjectName>
      <AbsolutePath>wwwroot\\data</AbsolutePath>
    </MsDeploySkipRules>
   </ItemGroup>

这是我的.pubxml 文件:

    <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <PropertyGroup>
        <DeleteExistingFiles>False</DeleteExistingFiles>
        <ExcludeApp_Data>False</ExcludeApp_Data>
        <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
        <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
        <LastUsedPlatform>Any CPU</LastUsedPlatform>
        <PublishProvider>FileSystem</PublishProvider>
        <PublishUrl>C:\www\VisualStudio2019-Core3</PublishUrl>
        <WebPublishMethod>FileSystem</WebPublishMethod>
        <SiteUrlToLaunchAfterPublish />
        <TargetFramework>netcoreapp3.1</TargetFramework>
        <ProjectGuid>881d6bfb-ed04-41d7-b600-0e26765ff90e</ProjectGuid>
        <SelfContained>false</SelfContained>
      </PropertyGroup>

Tried putting code here -->>

    </Project>

这是我的.csproj 文件:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <RootNamespace>VisualStudio2019_Core3</RootNamespace>
    <UserSecretsId>93d2ec1f-4bcc-4aa5-ad65-4bdbdce5690a</UserSecretsId>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.3" />
    <PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="3.1.5" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.2" />
    <PackageReference Include="Oracle.ManagedDataAccess.Core" Version="2.19.60" />
  </ItemGroup>

Tried putting code here -->>
  
</Project>

附加信息:

  • Visual Studio 2019
  • Web 应用程序核心 3.1
  • 通过 Studio 菜单发布...而不是命令行。

【问题讨论】:

    标签: visual-studio-2019 asp.net-core-3.1 web-application-project


    【解决方案1】:

    我在结束标签 PropertyGroup 之后使用了这个(指我的 webapp)

    <ItemGroup>
        <Content Remove="appsettings.Development.*" />
        <Content Remove="bundleconfig.json" />
        <Content Remove="wwwroot\js\Site.js" />
        <Content Remove="wwwroot\js\webcam-easy.js" />
        <Content Remove="wwwroot\js\webcam-app.js" />
        <Content Remove="wwwroot\css\Site.css" />
    
        <Content Update="wwwroot\js\Site.js" CopyToPublishDirectory="Never" />
        <Content Update="wwwroot\js\webcam-easy.js" CopyToPublishDirectory="Never" />
        <Content Update="wwwroot\js\webcam-app.js" CopyToPublishDirectory="Never" />
        <Content Update="wwwroot\css\Site.css" CopyToPublishDirectory="Never" />
    
        <ResolvedFileToPublish Include="wwwroot\css\xxxxx.min.css">
            <RelativePath>wwwroot\css\xxxxx.min.css</RelativePath>
        </ResolvedFileToPublish>
        <ResolvedFileToPublish Include="wwwroot\js\xxxxx.min.js">
            <RelativePath>wwwroot\js\xxxxx.min.js</RelativePath>
        </ResolvedFileToPublish>
        <MsDeploySkipRules Include="connectionconfig">
            <ObjectName>filePath</ObjectName>
            <AbsolutePath>connection.json</AbsolutePath>
        </MsDeploySkipRules>
      </ItemGroup>
    

    【讨论】:

      猜你喜欢
      • 2020-04-02
      • 2014-08-12
      • 1970-01-01
      • 2010-10-31
      • 2021-11-16
      • 1970-01-01
      • 2015-09-16
      • 2017-12-29
      • 2017-04-13
      相关资源
      最近更新 更多