Reputation: 760
I have an MVC5 project and I use Visual Studio 2019, to do my deployment using the deployment profiles.
In the root of the folder I have a few files (e.g. png files) that I prefer not to see in the Solution Explorer. However, I need them to get published.
Is there anyway to do this?
Upvotes: 0
Views: 218
Reputation: 40563
Please remove them from solution file or csproj file but leave them in source control. However, please bear in mind that by default publish profiles are excluded from source control by default gitignore for visual studion. This is because they contains sensitive data and as this they should not be stored in source control. If you need them to deploy code and you use Azure DevOps please consider using secure files.
If you want to include files which are not in the project you may follow this ASP.NET Web Deployment using Visual Studio: Deploying Extra Files. There you find information how to modify publish profiles to include additional files:
<Target Name="CustomCollectFiles">
<ItemGroup>
<_CustomFiles Include="ExtraFiles\**\*" />
<FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
<DestinationRelativePath>%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
</Target>
Note: you might need to use:
<_CustomFiles Include="..\ExtraFiles\**\*" />
Upvotes: 1