Publishing external configuration files in ASP.Net MVC project using Visual Studio
Asked Answered
O

1

2

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

Note: I have set properties of these external config file as: BuildAction : Content, Copy always too but didn't change anything!

Has anybody come up with a solution for this?

Thanks

Orthogenic answered 24/5, 2013 at 10:36 Comment(2)
Do you need something like this? #2747581Rhinology
@matt that's it. Voting to close as dupe. If you want to compose your own version of the correct answer I'll throw you the bounty, as you had the correct answer first.Daemon
E
0

Modify your 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

European answered 11/8, 2013 at 15:2 Comment(1)
More like copied from this answer :/ But at least the correct answered dupe has been located.Daemon

© 2022 - 2024 — McMap. All rights reserved.