4
votes

I am attempting to run a build programmatically and when building any Silverlight content get the message: "C:\Program Files (x86)\MSBuild\Microsoft\Silverlight\v4.0\Microsoft.Silverlight.Common.targets(104,9): error : The Silverlight 4 SDK is not installed.", but I have installed the Silverlight 4 SDK (many times).

I attempt to do the build basically like this:

var logger = new FileLogger();
logger.Parameters = @"logfile=" + buildLogFileName;

var projectToBuild = Microsoft.Build.Evaluation.ProjectCollection.GlobalProjectCollection.LoadProject(buildFile.FullName);
                projectToBuild.SetProperty("Configuration", "Release");
var successfulBuild = projectToBuild.Build(logger);

I have tried a number of workarounds and suggestions, but everything just sort of leads to other error messages. It seems like the best course would be to get it to understand that the Silverlight 4 SDK IS installed, but not sure how to do that? Or if there is something I'm missing here.

4
I don't have Silverlight SDK installed at the moment. Try to take a look on what exactly has been checked in C:\Program Files (x86)\MSBuild\Microsoft\Silverlight\v4.0\Microsoft.Silverlight.Common.targets(104,9)Sergio Rykov
What is the environment in which the code above is being executed? I'm assuming the build works from a VS command line, so what is different?Brian Kretzler
In the .targets file it looks like there is a $(TargetFrameworkSDKDirectory) but when we check that (via build messages) it is blank, not sure where it gets that initial value from? Is there a silverlight target that needs to be set or similar?ChrisHDog
The code above is being executed on a developer machine (windows 7 x64 with VS2010), the VS2010 build does work, but the code does not (though the code above does work for non-silverlight projects).ChrisHDog

4 Answers

2
votes

If your build server has a 64-bit OS, this post is quite useful. It tells of forcing the build to 32-bit for Silverlight.

1
votes

In your .csproj-File, replace the tag WindowsPhone71 by WindowsPhone

0
votes

If setting build to X86 and reinstalling Silverlight SDK 4 was not helpful: If you are using VS2013 on the build server, check if Windows Phone SDK is installed. I had to go run VS2013 installer, click change button and install windows phone sdk.

Or try to install windows phone sdk to be able to build windows phone solutions.

0
votes

I was getting the same error, changed form AnpCPU|Relase to X86|Release

folow the suggestion on http://joychua97.blogspot.com/2012/02/fixing-silverlight-4-sdk-is-not.html

C:\Program Files (x86)\MSBuild\Microsoft\Silverlight\v4.0\Microsoft.Silverlight.Common.targets (104): The Silverlight 4 SDK is not installed.

Looking around, they said that "Silverlight projects cannot be built by 64-bit MSBuild."

To resolve this: 1) Edit your Build Definition, and go to the Process tab 2) Expand the "3. Advanced" section and set the "MSBuild Platform" value to "x86" 3) Save the Build Definition.