Publish external configuration files in an ASP.Net MVC project using Visual Studio

I have an ASP.net MVC 4 web application, and web.config links to some other external configuration files (e.g.). When publishing a website, only web.config is published, and none of these external files will be deployed.

Note. I set the properties of this external configuration file as: BuildAction: Content, Copy always too, but nothing changed!

Has anyone come up with a solution for this?

thanks

+2
source share
1 answer

Modify the project file as such:

<PropertyGroup> <CopyAllFilesToSingleFolderForPackageDependsOn> CustomConfigFiles; $(CopyAllFilesToSingleFolderForPackageDependsOn); </CopyAllFilesToSingleFolderForPackageDependsOn> <CopyAllFilesToSingleFolderForMsdeployDependsOn> CustomConfigFiles; $(CopyAllFilesToSingleFolderForPackageDependsOn); </CopyAllFilesToSingleFolderForMsdeployDependsOn> </PropertyGroup> <Target Name="CustomConfigFiles"> <ItemGroup> <YourCustomConfigFiles Include="..\Path\To\Your\**\*.config" /> <FilesForPackagingFromProject Include="%(YourCustomConfigFiles)"> <DestinationRelativePath>Target\Path\For\Your\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath> </FilesForPackagingFromProject> </ItemGroup> </Target> 

based on this answer

0
source

Source: https://habr.com/ru/post/1210573/


All Articles