Error doing web.config transformation for different environments

坚强是说给别人听的谎言 提交于 2019-11-30 16:50:22

问题


I was trying to deploy my app into different environments then i started following this how to: Deploying an ASP.NET Web Application to a Hosting Provider using Visual Studio or Visual Web Developer: Web.Config File Transformations - 3 of 12

was perfect until I clicked in Preview Transform, I received this error:

Microsoft Visual Studio

Could not load file or assembly 'Microsoft.Web.XmlTransform, Version=1.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

(I created just one transformation Web.DebugQA.config and of course the default ones, debug and release)

my Web.DebugQA.config looks like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <connectionStrings>
    <add name="MyDB" 
      connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True" 
      xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
  </connectionStrings>
  <system.web>
  </system.web>
  <appSettings>
    <add key="EnvironmentName" value="QADev" xdt:Transform="SetAttributes(value)"
      xdt:Locator="Match(key)" />
  </appSettings>
</configuration>

but then I install this plugin:

SlowCheetah - XML Transforms

and I solved my preview transform error, but then when I was trying to publish using the QADev transform I got this error:

The "ImportParametersFile" task failed unexpectedly.

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Web.XmlTransform, Version=1.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. File name: 'Microsoft.Web.XmlTransform, Version=1.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
at Microsoft.Web.Publishing.Tasks.ImportParametersFile.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext()

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

I'm using Visual Studio Pro 2012.


回答1:


I fixed this by repairing "Microsoft ASP.NET and Web Tools 2013.1 - Visual Studio 2012" from Control Panel --> Programs and Features.

The file Microsoft.Web.XmlTransform.dll was missing from the path C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web.




回答2:


I had a similar error, although it was caused for different reasons.

I solved it copying the following DLL from another PC with VS2012 installed: Microsoft.Web.XmlTransforms.dll

from: C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web

I hope this helps




回答3:


I had same problem in VS2012, could not 'Preview Transform' for the PublishPackage tranforms e.g. Web.Staging.config complaining about Microsoft.Web.XmlTransform

I got it working by adding the Package https://nuget.org/packages/Microsoft.Web.Xdt to my Mvc 4.5 project. This package is still in pre release.

PM> Install-Package Microsoft.Web.Xdt -Pre

This package contains the Microsoft.Web.XmlTransform.dll

I still get an error during building complaining about "Could not load file or assembly Microsoft.Web.XmlTransform". The Mvc project has still built ok.

I did try adding the Microsoft.Web.XmlTransform.dll to the Gac using the gacutil but that did not fix the problem.

However I use Team Foundation Service build server and it works and creates the correct Web.config after applying the Web.Release.config and then the Web.Staging.config.




回答4:


I tried below two things but it did not work for me.

1) copying the Microsoft.Web.XmlTransforms.dll DLL to location C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web

2) And repairing "Microsoft ASP.NET and Web Tools 2013.1 - Visual Studio 2012"

Then I uninstalled Microsoft Azure tool V2.6 from control panel -> Programs and Features. And then I can able to publish my site.




回答5:


This may have been fixed in Visual Studio 2012 Update 2 (and Visual Studio 2013).

Web.config "Preview Transform" gives an error

...

Posted by Microsoft on 3/1/2013 at 2:46 PM

Thanks for reporting the issue! It will be fixed in Visual Studio 2012 Update 2. Please install it when it becomes available.



来源:https://stackoverflow.com/questions/14776659/error-doing-web-config-transformation-for-different-environments

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!