如何解决MsDeploySkipRules 在项目发布时被忽略
我想排除 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>
附加信息:
解决方法
我在结束标记 PropertyGroup 之后使用了这个(指的是我的 web 应用程序)
<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>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。