17

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=4.0.0.0, 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 
  /t:rebuild 
  /verbosity:quiet 
  /filelogger 
  /fileloggerparameters:LogFile=c:\Dev\MarketWatch\build\Logs\capture.msbuild.log

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.
Bevan
  • 43,618
  • 10
  • 81
  • 133

3 Answers3

43

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.

Kevin Gosse
  • 38,392
  • 3
  • 78
  • 94
  • The same applies to Mindscape.*.Design assemblies; thank you for saving me a lot of trouble. – Ed Noepel Jul 12 '12 at 14:43
  • 1
    This was my problem after using Install-Package Microsoft.Expression.Blend.SDK.WPF Deleting the .design assemblies did the trick. Thanks. – tourdownunder Aug 21 '13 at 05:33
  • The same appears to apply to Infragistics .design assemblies. –  Oct 16 '13 at 06:21
  • Uh, thank god there is nothing maven-like in C# so ppl can waste endless hours on issues like that... thanks for saving us this time man! – Kranach Jun 06 '14 at 12:42
  • This can solve the compilation issue but by doing this you will not be able to use the designer functionalities of the source code you tried to compile. I solved the issue by installing the Visual Studio SDK on the machine of the compilation and it worked fine. – Gabriel Vonlanten C. Lopes Jul 25 '14 at 19:15
0

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.

lokusking
  • 7,396
  • 13
  • 38
  • 57
0

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?

Sergio Rykov
  • 4,176
  • 25
  • 23
  • Good suggestion, but I'm already running my build script from a VS2010 command prompt. I'll update the question to indicate this. – Bevan Apr 13 '11 at 21:04
  • I found a couple of links that talk about (mis)use of reflection - but they're all about code written wrong. My problem isn't ocurring at runtime, but at *compile* time. – Bevan Apr 15 '11 at 02:16