Error doing web.config transformation for differen

2019-02-12 09:43发布

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.

5条回答
干净又极端
2楼-- · 2019-02-12 10:06

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.

查看更多
等我变得足够好
3楼-- · 2019-02-12 10:09

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.

查看更多
神经病院院长
4楼-- · 2019-02-12 10:11

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.

查看更多
混吃等死
5楼-- · 2019-02-12 10:14

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

查看更多
戒情不戒烟
6楼-- · 2019-02-12 10:24

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. & now I can able to publish my site.

查看更多
登录 后发表回答