سؤال

based on what i read, as long as you have a transform that matches the name of a publish profile, it should be applied, but this is not the case for me.

publish profiles

PublisProfiles
    dev.pubxml
    local.pubxml

transforms

 Web.Config
     Web.Debug.config
     Web.local.config
     Web.Release.config

when i publish using local config, i see this:

Transformed Web.config using  C:\...\Web.Release.config into obj\Release\TransformWebConfig\transformed\Web.config.

so it's using Release.config .. i opened up local.pubxml and tried changing this

<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>

to:

<LastUsedBuildConfiguration>local</LastUsedBuildConfiguration>

but then it's using Web.Debug.config transform.

dev, release, local transforms are identical aside from a few transformed properties ..

هل كانت مفيدة؟

المحلول

seems like a bug, because i finally got it to work by:

  1. delete Web.Debug.config

  2. publish local (my Web.local.config is now being applied)

  3. right click on Web.Config "Add Config Transform" in order to bring back Web.Debug.config

  4. confirmed that the transform still works

نصائح أخرى

The publish pipeline should be using both your profile's transform and the build configuration transform.

The logic for this is that your profile transform probably has destination-specific settings (e.g. which connection strings to use in Production vs. Staging), but your build configuration has build-specific settings (e.g. Debug has debugging related settings but Release turns them off). Allowing you to mix and match these gives greater flexibility (need to publish to Staging with debug settings enabled? Just use the Debug build configuration with the Staging profile). Settings from web.YourProfile.config will always overrule any prior transforms.

My problem with that had to do with the platform configuration:

At the Configuration Manager window, you can choose the config name ("Active solution configuration" combobox) and the target platform ("Active solution platform" combobox). I correctly made the setup of my new configuration ("MyStagingConfig", say) for each project, but forgot about the platform - so I configured it all in "Mixed platform".

When I published the project using "MyStagingConfig - Any CPU", it transformed the config with the Web.Staging.config file, instead of Web.MyStagingConfig.config. After a little headache, I realised that the "Any CPU" platform, which I hadn't configured, was configured by default to publish the project with the "Staging" config (as I had imported the settings from the "Staging" config when creating "MyStagingConfig").

In Configuration Manager, check each "Active solution configuration" and make sure the "Configuration" column is correct for each project. (In my case, a developer had accidentally changed one of these values.)

In your csproj you will find code that looks like ...

  <Target Name="BeforeBuild" Condition="'$(PublishProfileName)' == '' And '$(WebPublishProfileFile)' == ''">
    <TransformXml Source="Web.config" Transform="Web.$(Configuration).config" Destination="Web.config" />
  </Target>

This is the default. Note, you can modify this, but I am not recommending this.

What I recommend is that you check your build configuration settings. Select Build > Configuration Manager from the menu. Verify that the configuration selected for your project is the configuration that you want to use. I.E. In the second column if you have Release selected for your main build project where the web.config is, you will have the Release transform even if your solution configuration is titled Debug. Change Release to Debug (or the appropriate setting) and it will fix your issue.

In VS2015 there is also a bug, but little different: in my case I saw that when I created a new profile on the solution level, it would not be chooseable for the mvc project. It does not even appear in the dropdown.

However, when I clicked New from the mvc project (with checkbox "Create new solutions configuration" checked), only then the new profile would appear with my mvc project.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top