23

I want to publish a MVC project and I keep getting this error:

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Web.XmlTransform', Version=1.4.0.0, Culture=neutral, PublicKeyToken=... or one of its dependencies. The system cannot find the file specified.

I have searched for and tried some solutions found on SO or MSDN to no avail. I'm really desperate for some suggestions. The project has been published successfully before, but this came out of the blue after trying to republish my updated version.

Jester
  • 56,577
  • 4
  • 81
  • 125
barca_d
  • 1,031
  • 2
  • 13
  • 30
  • Is this assembly reference in your `.csproj` file directly, or is it a dependency of another dependency? – Martin Costello Apr 28 '14 at 12:55
  • It is referenced directly. However, I don't remember it to be referenced directly before attempting the solution presented here: http://stackoverflow.com/questions/14776659/error-doing-web-config-transformation-for-different-enviroments Still the error was the same before as it is now – barca_d Apr 28 '14 at 12:57
  • Have you got the reference set to `CopyLocal=true` in the Properties window in Visual Studio? If not, it might explain the missing file if you're deploying using a technology such as MSDeploy. If that isn't it, then maybe you have another dependency somewhere expecting a different version of the assembly. In that case you'd need to add an appropriate `bindingRedirect` to `Web.config`. – Martin Costello Apr 28 '14 at 12:59
  • Yes, I checked the copyLocal and it is set to true. I tried a binding redirect and it did not work (sth like this: – barca_d Apr 28 '14 at 13:02

13 Answers13

18

I finally got this to work. I'm leaving my solution here in case others have a similar issue.

Basically I tried repairing my VS using the Microsoft ASP.NET and Web Tools 2013.1 (I got it from here Microsoft Web Tools download page). However, it didn't solve the problem for me. What did solve it was copying the file Microsoft.Web.XmlTransforms.dll from another machine at the location

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

Somehow, mine was missing from there (I got it from another computer with the same .NET version and pasted it there) and now the publish works fine.

barca_d
  • 1,031
  • 2
  • 13
  • 30
  • 2
    In my case DLL disappeared after VS2013 installation. Your solution helped. Thanks! – the_joric Dec 12 '14 at 17:16
  • This doesn't help if you don't have Visual Studio 2012 installed — either because you have VS Express installed or because you're on a build server — unfortunately. – Owen Blacker Feb 19 '15 at 18:30
18

Repairing "Microsoft ASP.NET and Web Tools 2013.1 - Visual Studio 2012" from Control Panel re-added the dll for me (what was missing, apparently after I updated the said package a few weeks ago).

Piedone
  • 2,693
  • 2
  • 24
  • 43
  • Worked a treat for me. Had to restart VS after repair finished for it to work btw. – Chris Curtis Aug 29 '14 at 00:27
  • Repairing MS Web Tools for VS2012 worked for me too and restored the missing file – Thomas Kelly Oct 30 '14 at 01:32
  • If you don't have VS2012 installed — because you're a build server or you have 2012 Express or you have 2010 and 2013 but nothing in between (my problem), this package won't be present and won't install from scratch. – Owen Blacker Feb 20 '15 at 11:27
3

Repairing MS Web Tools for VS2012 did not solve the problem for me.

I have the files in the folder C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web (I do not know if this is because I have installed VS 2013 Express, or some other tool. Maybe installing the Web Tools for VS 2013 will create them).

Copying the files from v12.0 folder to v11.0 folder fixed the problem.

Owen Blacker
  • 4,117
  • 2
  • 33
  • 70
d.popov
  • 4,175
  • 1
  • 36
  • 47
  • That didn't work for me, presumably because the file in my `v12.0` folder is versioned 2.0 and may have a different `PublicKeyToken`. – Owen Blacker Feb 19 '15 at 18:29
  • 1
    @OwenBlacker: I faced the same issue. According to the stacktrace Microsoft.Web.Publishing.Tasks was calling Microsoft.Web.XmlTransform, so I copied both dll's. That solved my problem. – Henk van Boeijen Aug 21 '15 at 15:34
3

Had that problem also. What worked for me was:

iamkrillin
  • 6,798
  • 1
  • 24
  • 51
bicycle
  • 8,315
  • 9
  • 52
  • 72
  • That doesn't help if you don't have Visual Studio 2012 installed — either because you have VS Express installed or because you're on a build server. – Owen Blacker Feb 19 '15 at 18:28
2

This may be an edge case, but I cloned I co-workers GIT repo containing a Visual Studio solution.

Visual Studio was reporting that the Microsoft.Web.XmlTransform.dll reference was broken.

Looking at the .csproj file for that project I found this:

<HintPath>..\..\..\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.Web.XmlTransform.dll</HintPath>

This path must have been correct for my co-worker, but for me it was wrong. I corrected to this:

<HintPath>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.Web.XmlTransform.dll</HintPath>


This occured with VS2015 (Version 14 Update 2).

harvzor
  • 2,832
  • 1
  • 22
  • 40
1

run VS12 in admin mode helped me after I tried all recommended above

  • Good idea. Not the solution to my problem, but I often forget to do this as a troubleshooting step. – pbristow Dec 08 '15 at 15:44
0

Have you tried using the Assembly Binding Log Viewer, this may give more information...

http://msdn.microsoft.com/en-us/library/e74a18c4(v=vs.110).aspx

Justin Harvey
  • 14,446
  • 2
  • 27
  • 30
  • I did not downvote your answer, but I think it was downvoted b/c the assembly binding happens during compilation. The error in the OP happens during the various processes that run during publishing, like packaging, creating config files, and all that "magic". I don't think assembly binding would ever be relevant to the OP. – pbristow Dec 08 '15 at 15:43
0

Download file from here: https://docs.google.com/file/d/0B8XrlgnW-cfISXd1Q0VQb0gtNk0/edit

and place it here: C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web

Enjoy !

user2626270
  • 258
  • 2
  • 6
  • 2
    I am so not taking a DLL from "some guy on the Internet" somewhere and putting it on one of our servers ;) – Owen Blacker Feb 20 '15 at 14:38
  • I wanted to help you, because this DLL is not available by itself. unless you download entire package. – user2626270 Mar 03 '15 at 12:35
  • 2
    Oh, I know you're trying to help and it's very much appreciated. But it's poor security advice to take a DLL from someone I don't know and trust :) In the end, I've used precisely this solution, but from an ex-colleague. Thank you, though! :) – Owen Blacker Mar 03 '15 at 16:46
0

My situation seems to have been caused when I installed the Azure 1.1 SDK and components for Service Bus for windows. The publish to Azure kept failing for transformation errors, went back to some of my other projects that were just web package installs, and again those transforms failed for the same error, so now I have a bigger problem. My POC now is breaking my production deploys. I removed and re-installed Microsoft ASP.Net and WebTools 2013.v - Visual Studio 2012 from the control panel which did not help. Rebooted the machine and then just did a repair on the same component, and Voila, seems to work fine now.

Jen S
  • 4,465
  • 1
  • 32
  • 28
JMAC
  • 1
0

I had a nearly identical problem, except the publish was saying it couldn't find Newtonsoft.Json.dll, Version=4.5.0.0. I tried all of the above solutions before finally realizing that the file was missing from the package directory for Azure WebJobs Publish (apologies for not having the full name of the package at my fingertips). The solution was simply to empty my entire /packages/ folder and let them restore automatically.

pbristow
  • 1,997
  • 4
  • 26
  • 46
0

For me 'barca_d' solution worked but i also had to keep my projects

Minions
  • 27
  • 9
0

Hope my solution would help someone.

There was a installed program called "Microsoft ASP.NET and Framework 2012.2", uninstall it and then repair the Microsoft Visual Studio Professional 2012, works fine now

Installed Programs (Control Panel-->Programs and Features)

Microsoft .NET Framework 4.5

Microsoft ASP.NET MVC 3

Microsoft ASP.NET Web Pages

Microsoft Visual Studio Professional 2012 with update 5

Microsoft Web Deploy 3.5

Feng
  • 1
  • Hi, it seems you have 2 accounts; http://stackoverflow.com/users/6810759/feng and http://stackoverflow.com/users/6810728/feng. Please follow the steps at http://stackoverflow.com/help/merging-accounts if you want to merge them – Matt Sep 21 '16 at 12:28
0

Reinstall NuGet Package Microsoft.Web.Xdt

opis-kladno
  • 117
  • 5