0

I'm doing an automated publishing using VSTS, the whole process performs publishing on multiple servers, and each has its own specific settings in WEB.config. I was deleting WEB.config before I threw the publication files into the folder so I was not replacing the existing one, but this caused some problems.

The solution I found was to use additional files to complement WEB.config, so in AppSettings I used the file = "" attribute to link other settings from other archives called WebAppSettings.config.

This WebAppSettings.config files has None as a compilation action, so at the time of publication it is ignored and when the files are dropped into the folder, and it does not overlap the current one.

But when attempting to do the same with ConnectionStrings, using the configSource = "" attribute to indicate the WebConnectionStrings.config add-in file, it fails during the pruning because the build does not accept that the file has as compilation action other than Content, if I put None or additionalfiles, it simply says error that can not find the file.

Do you have any way around it? How to make WebConnectionStrings.config work with None? I figured it would work the same way as AppSettings. I could not find anything in my research to help with this WEB.config issue.

Publication is done with Pre views compiled using AspNetPreCompile MSBUILD Arguments:

/p:DeployOnBuild=true /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\" /p:WebPublishMethod=FileSystem /p:PrecompileBeforePublish=true /p:EnableUpdateable=false /p:DebugSymbols=false /p:WDPMergeOption=MergeAllOutputsToASingleAssembly /p:UseMerge=true /p:SingleAssemblyName=AppViews

WEB.config

[...]

<connectionStrings configSource="WebConnectionStrings.config"></connectionStrings>

<appSettings file="WebAppSettings.config">
    <add key="webpages:Version" value="3.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="PreserveLoginUrl" value="true" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
    <add key="MvcFlashMessages/IsClosable" value="true" />
    <add key="MvcFlashMessages/InnerCssClass" value="alert" />
</appSettings>

[...]

1
  • Why you need to delete the web.config and can't replace the existing one? Replace the existing web.config is easy. Commented Jan 29, 2018 at 5:19

1 Answer 1

1

Build-action of "Content" is correct, you don't want to change that. It appears your underlying problem here is how to setup your project to support VSTS build/releases.

During the VSTS build creation, any .config files with

<DependentUpon>Web.config</DependentUpon>

are going to be deleted as part of the build process. You don't want that if you are later going to transform the files during the release.

To get by this, you need to remove the DependentUpon tag in the project (.csproj/.vbproj) file. This will keep all the config files for various environments all visible in solution explorer, don't worry though, it doesn't break anything.

I'd also make the suggestion that splitting up the files are not necessary in this case, you can get this all back to a single Web.config file.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.