What causes a "Cannot resolve dependency error" from MsBuild?

I'm trying to set up some build scripts for continuous integration and I'm finding something weird.

My solution compiles fine from Visual Studio 2010, but fails with an error when I build the exact same thing from the command line with MSBuild.

Here's the error I get from the commandline build.

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.WinFX.targets(269,9): error MC1000: Unknown build error, 'Cannot resolve dependency to assembly 'Microsoft.Windows.Design.Extensibility, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event.' [C:\Dev\Market Watch\src\Console\MarketWatch.Console\Rbnz.MarketWatch.Console.csproj]

I've checked through all my source code for references to Microsoft.Windows.Design.Extensibility and haven't found any at all. I've also checked all the binaries we reference from this project, including some DevExpress libraries.

My MSBuild commandline looks like this:

MsBuild.exe c:\Dev\MarketWatch\src\Capture\Capture.sln 

Is there something missing that I should include on the MsBuild commandline to make commandline builds work just the same as those run by Visual Studio?

Update 14/4

  • I'm getting these errors despite running the build script from a Visual Studio command prompt.


I hope you solved the problem, but for future reference:

I just had the same problem, and it comes from DevExpress '.design' assemblies. You're actually not supposed to reference those in your project. Remove all references to DevExpress assemblies ending with '.design' and it should work.

You should initialize paths to find assemblies, tools and so on. Call vcvarsall.bat before calling msbuild:

call "%ProgramFiles%\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x64

Or open VS2010 command line console and call your script from it. Both actions has the same effect.

EDIT: I couldn't understand one thing - google for your question says that you use Reflection in a wrong way, and one of possible solutions is described here. Am I right?

I recently encountered the same issue.

The Error was thrown on our VSTS-BuildAgent. After following all advices from Devexpress sites (including Project-Upgrade), the Error was still there.

To be honest, we are mixing WinForms and WPF for a smooth migration from Winforms to WPF, so basically not an everyday-problem.

Anyway, i was able to fix this, by adding all needed references to WPF-Project again, even if they are all already referenced in the Start-Project, which is Winforms.

After this move, the BuildAgent was able to succeed the Build.

Need Your Help

JUnit Exception Testing

java unit-testing exception junit junit3

Edit: Not JUnit 4 available at this time.