2021年4月27日星期二

Can't exclude web.config file while publishing using dotnet publish command

I have a dot net core 3.1 project. When I run my application using IIS it creates a web.config file automatically by adding environment ASPNETCORE_ENVIRONMENT" = "Development". Since I am deploying my application to Azure and managing configuration via application settings, I don't need to publish the web.config file in my artifact folder. Also, the added ASPNETCORE_ENVIRONMENT causes change the ASPNETCORE_ENVIRONMENT from Staging/Production to Development as well. I wanted to exclude the web.config while publishing. I have tried with different approaches suggested online but nothing works like:

    <ItemGroup>          <Content Remove="web.config" />      </ItemGroup>        <ItemGroup>          <Content Update="web.config">              <CopyToOutputDirectory>Never</CopyToOutputDirectory>          </Content>      </ItemGroup>        <ItemGroup>          <Content Update="web.config">              <CopyToPublishDirectory>Never</CopyToPublishDirectory>          </Content>      </ItemGroup>  

But it always includes the web.config file in published directory for dotnet publish command. Is there anything I am missing here?

https://stackoverflow.com/questions/67287736/cant-exclude-web-config-file-while-publishing-using-dotnet-publish-command April 28, 2021 at 01:15AM

没有评论:

发表评论