0

I have a ASP.NET Core 2.2 white label app with a separate config.json file. I want to be able to exclude this file from being deployed when I call dotnet publish (from VS Code) so that I don't accidentally overwrite my UAT and Prod setups.

With ASP.NET you could add <ExcludeFilesFromDeployment> inside <PropertyGroup>. I've tried this in my .csproj file but it doesn't seem to be working and I can't find any reference to this element in the asp.net core docs. It looks like it might be an outstanding issue according to https://github.com/aspnet/vsweb-publish/issues/73

In previous versions of Core you could use publishExclude in the project.json file but that doesn't exist in ver 2.2

How can I exclude files on a dotnet publish?

1 Answer 1

1

For Asp.Net Core 2.2, it uses MSBuild to build the project.

For ingoring the specific file, you could edit the *.csproj with adding below

<ItemGroup>
    <Content Update="config.json" CopyToPublishDirectory="Never" />
</ItemGroup>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.