dotnet publish
我的 ASP.NET Core 3.1 项目的命令创建了一个 web.config
文件在我的 publish/
目录。我不希望生成此文件(或至少将其复制到该文件夹中)-它根本不会与 IIS 一起使用。
当我查看详细程度增加的命令输出时,我发现了以下文本:
Target "_TransformWebConfig" in file "C:\Program Files\dotnet\sdk\3.1.200\Sdks\Microsoft.NET.Sdk.Publish\targets\TransformTargets\Microsoft.NET.Sdk.Publish.TransformFiles.targets" from project "C:\repos\reportweb\reportweb\reportweb.csproj" (target "_AspNetCoreProjectSystemPostPublish" depends on it):
Using "TransformWebConfig" task from assembly "C:\Program Files\dotnet\sdk\3.1.200\Sdks\Microsoft.NET.Sdk.Publish\targets\..\tools\netcoreapp2.1\Microsoft.NET.Sdk.Publish.Tasks.dll".
Task "TransformWebConfig"
Configuring the following project for use with IIS: 'C:\repos\reportweb\reportweb\bin\Release\netcoreapp3.1\linux-x64\publish\'
Updating web.config at 'C:\repos\reportweb\reportweb\bin\Release\netcoreapp3.1\linux-x64\publish\web.config'
Configuring project completed successfully
Done executing task "TransformWebConfig".
Done building target "_TransformWebConfig" in project "reportweb.csproj".
是否可以将我的项目配置为跳过
_TransformWebConfig
目标或 TransformWebConfig
任务 - 还是使用另一种方式跳过生成?我知道我可以让 MSBuild 之后删除文件,但是禁用此功能对我来说似乎不那么麻烦。
最佳答案
您可以使用 IsWebConfigTransformDisabled
来控制它MSBuild 属性:
To prevent transformations of the web.config file, set the MSBuild property
$(IsWebConfigTransformDisabled)
:dotnet publish /p:IsWebConfigTransformDisabled=true
因为这是一个 MSBuild 属性,您可以在 .csproj 中设置它,而不是将它作为命令行参数传递:
<PropertyGroup>
<IsWebConfigTransformDisabled>true</IsWebConfigTransformDisabled>
</PropertyGroup>
关于asp.net-core - 禁用 asp.net core 3.1 项目的 web.config 生成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61613653/