1

In Visual Studio 2015 ASP.NET MVC project I am using "File System" publish method for project publishing. Additionally I want to include custom JSON configuration file (settings_dev.conf) in publishing process. By default this file is not published to file system.

  1. Is it possible to include single file in publish profile configuration?
  2. Is it possible to change the name of published file? From "settings_dev.conf" to "settings.conf".

Below is the configuration which I have tried.

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>FileSystem</WebPublishMethod>
    <LastUsedBuildConfiguration>Dev</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish />
    <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
    <ExcludeApp_Data>False</ExcludeApp_Data>

    <DeleteExistingFiles>False</DeleteExistingFiles>    

    <CopyAllFilesToSingleFolderForPackageDependsOn>
      Settings;
      <!--$(CopyAllFilesToSingleFolderForPackageDependsOn);-->
    </CopyAllFilesToSingleFolderForPackageDependsOn>    
  </PropertyGroup>

  <Target Name="Settings">
    <ItemGroup>
      <_CustomFiles Include="$(MSBuildProjectDirectory)\settings_dev.conf" />
      <FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
        <DestinationRelativePath>%(RecursiveDir)settings.conf</DestinationRelativePath>
      </FilesForPackagingFromProject>
    </ItemGroup>
  </Target>
</Project>

Using this configuration all files get published. I have other settings.conf files for different environments.

Viktors Telle
  • 763
  • 9
  • 22
  • Slowcheetah used to do this kind of thing, but it work with xml files and is not in development anymore. Probably your best choice is to make a msbuild task to do this. You can check MSBuild Community Tasks to get ideas on how to do it. – Luiz Sep 28 '15 at 12:17

0 Answers0