Question

I am using the Microsoft.Build.BuildEngine to build a number of projects. Projects that do not use Silverlight are building correctly while projects that do use Silverlight are not building. All of these projects (Silverlight and non-Silverlight) all build fine through Visual Studio 2008. I get the error message:

error CS0234: The type or namespace name 'SilverlightControls' does not exist in the namespace 'System.Web.UI' (are you missing an assembly reference?)

I've added System.Web.Silverlight to the project that is doing the build using Microsoft.Build.BuildEngine. I am able to see that namespace in the project doing the build also (so it appears that the project doing the build does have access to System.Web.UI).

Any ideas on how I can avoid that error?


Turned up the verbosity on the build through VS2008 and compared to the log created from the Microsoft.Build.BuildEngine. It looks like the Microsoft.Build.BuildEngine is producing lines like:

Considered "c:\Program Files\Reference Assemblies\Microsoft\Framework \v3.5\System.Web.Silverlight.dll", but it didn't exist.

It doesn't exist in that location, should it? There are actually a number of locations that it looks for that dll and doesn't find it. I added the reference by right clicking, add reference, .Net, add. There doesn't appear to be a System.Web.Silverlight.dll on my machine (which is odd because the project does compile using VS2008).

Comparing the possibly relevant sections of the two logs: Microsoft.Build.BuildEngine

For SearchPath "{GAC}". Considered "System.Web.Silverlight, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL", which was not found in the GAC.

Visual Studio 2008

System.Web.Silverlight, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL


Manually added System.Web.Silverlight to the path that the Microsoft.Build.BuildEngine was looking for it (coppied it from the output directory when I build the project via VS2008). This solved that problem, but I now get the following errors on the Silverlight components of the solution:

C:\Program Files\MSBuild\Microsoft\Silverlight \v2.0\Microsoft.Silverlight.Common.targets(95,9): error : The Silverlight 2 SDK is not installed.

Any ideas?

Was it helpful?

Solution

In the application that is running the Microsoft.Build.BuildEngine I changed the type of build from Any CPU to x86. This has now made the application be able to build the target as expected.

OTHER TIPS

So you're programmatically building using the MSBuild APIs?

It may be useful to add an ILogger (e.g. that just prints to the console) to engine.Loggers, and compare the output with the output window in VS (after setting e.g. 'tools\options\project & solutions\build & run\msbuild output verbosity' to verbose)... seems like somehow the environment is causing assemblies to resolve differently?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top