Ensuring Visual Studio Includes a Directory When Publishing

Yesterday I had an issue where I could not for the life of me figure out how to get a damn directory copied when doing a publish in Visual Studio.

I finally found the solution after digging through a ton of Microsoft Documentation and Stack Overflow.

If you are also trying to accomplish this, here is a quick snippet of my ViewController.csproj from my .NET Core app.

<Folder Include=”Certificates\” />
<CommonFiles Include=”Certificates\*” />
<ContentWithTargetPath Include=”@(CommonFiles)” TargetPath=”Certificates\%(FileName)%(Extension)” CopyToPublishDirectory=”Always” />

You’ll notice that I am trying to ensure the “Certificates” folder is copied which is at the base directory of the Project.

Included below is a picture of what it would look like in your own *.csproj

copying a file to the publish directory

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s