禁用asp.net core 3.1项目的web.config生成 [英] disable web.config generation for asp.net core 3.1 project

查看:917
本文介绍了禁用asp.net core 3.1项目的web.config生成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的ASP.NET Core 3.1项目的dotnet publish命令在我的publish/目录中创建一个web.config文件.我不希望生成此文件(或至少将其复制到该文件夹​​)-绝对不要将其与IIS一起使用.

The dotnet publish command for my ASP.NET Core 3.1 project creates a web.config file in my publish/ directory. I don't want this file to be generated (or copied to that folder, at least) - it is never to be used with IIS at all.

当我查看详细程度提高的命令输出时,发现以下文本:

When I took a look at the command output with verbosity increased, I found the following text:

   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之后删除该文件,但是禁用此功能对我来说似乎不太 .

Is it somehow possible to configure my project to skip the _TransformWebConfig Target or TransformWebConfig Task - or to use another way to skip the generation? I know I could make MSBuild delete the file afterwards, but having this disabled seems less hacky to me.

推荐答案

您可以使用

You can control this with the IsWebConfigTransformDisabled MSBuild property:

要防止转换web.config文件,请设置MSBuild属性$(IsWebConfigTransformDisabled):

dotnet publish /p:IsWebConfigTransformDisabled=true

由于这是MSBuild属性,因此可以在.csproj中进行设置,而不必将其作为命令行参数传递:

Because this is an MSBuild property, you can set it in the .csproj, instead of passing it as a command-line argument:

<PropertyGroup>
    <IsWebConfigTransformDisabled>true</IsWebConfigTransformDisabled>
</PropertyGroup>

这篇关于禁用asp.net core 3.1项目的web.config生成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆