Saturday, January 5, 2013

No Silverlight project specified for Silverlight output

No Silverlight project specified for Silverlight output

I have a very standard silverlight app running under an ASP.NET host. On all dev machines it compiles fine, but on our CI serve, we get this error:

No Silverlight project specified for Silverlight output

But if I log into CI and compile manually with VS2010 it works fine! This is Silverlight 4, .NET 4.0

Answers & Comments...

Answer: 1

As I just spent 2 days trying to figure out why this was happening in a Silverlight project I work on, I figured I'd post it here.

In my case, the problem was caused because one of the <ProjectReference> in website's .csproj had a project GUID which didn't match the actual GUID of the project (due to a code reorganization which had occured earlier).

This had nothing to do with the silverlight application or any of its settings. I have no idea why, but somehow this bad reference causes the "CopyFilesToFolders" MSBuild task to get a the same files listed multiple times in the "SourceFiles" list. This causes the first set of copys to succeed followed by a set of "No Silverlight project specified" errors.

Simply removing the bad project reference and re-adding it fixed the GUID and solved the build issue.

A very very bad error message indeed.

by : MerickOWAhttp://stackoverflow.com/users/419871

Answer: 2

Thanks to MerickOWA for posting here, I am sure it saved me hours with the same problem.

I have created a PowerShell script to find the mismatched GUIDs for all projects in a solution. It may save someone else even more hours.

To run it, copy the code below into a text file in the same folder as your solution, rename to .ps1, start up the Powershell console, navigate to the folder containing you solution, then run the script. It will list mis-matched project references, if any.

To fix, open the solution in Visual Studio then remove and re-add the mismatched Project Reference(s).

function validateSolution([string]$slnFileName) {      "Validating solution: " + $slnFileName      # Extract all the c# projects from the solution file     $solutionProjects =          Get-Content $slnFileName | Select-String 'Project\(' | ForEach-Object {             $projectParts = $_ -Split '[,=]' ;             New-Object PSObject -Property @{                 Kind = $projectParts[0].Replace('Project("', '').Replace('") ','');                 Name = $projectParts[1].Trim('" ');                 File = $projectParts[2].Trim('" ');                 Guid = $projectParts[3].Trim('" ');             };          } | Where-Object { $_.Kind -eq "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}" } # Kind = C# project      # Output list of C# projects to console     # $solutionProjects      # Create HashTable keyed on project GUID     $solutionProjectGuids = @{}     foreach ($project in $solutionProjects) {         $solutionProjectGuids.Add($project.Guid, $project)     }      # Loop through each c# project in the solution     foreach ($project in $solutionProjects) {         [xml]$projectXml = Get-Content $project.File         $projectReferences = $projectXml.Project.ItemGroup | Where-Object { $_.ProjectReference -ne $null }          # Loop through each ProjectReference         foreach($reference in $projectReferences.ChildNodes | Where-Object { $_.Project -ne $null } ) {             # Check the project reference GUID exists in hash table of project GUIDS; if not write error             if (!$solutionProjectGuids.ContainsKey($reference.Project)) {                 ""                 "Bad ProjectReference: Project GUID not found in solution "                  "Solution:  " + $slnFileName                 "Project:   " + $project.File                 "Reference: " + $reference.Name                 "Bad GUID:  " + $reference.Project             }         }     }     "Completed solution:  " + $slnFileName }  foreach ($solutionFile in ls *.sln) {     validateSolution $solutionFile } 
by : Edwardhttp://stackoverflow.com/users/158675

Answer: 3

If you take a look at the log file that is generated by your build server, you will probably see something like this...

CopySilverlightApplications:   Copying Silverlight applications   Copying <Path>.xap to <Path>.xap MSBUILD : error : Copying file <Path>.xap failed. No Silverlight project specified for Silverlight output <Path>.xap. [<Path>.csproj] 

CopySilverlightApplications is a target that is defined in the following file.

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\WebApplications\Microsoft.WebApplication.targets

It includes this condition which explains why you are not having the problem when building with Visual Studio.

Condition="'$(BuildingInsideVisualStudio)' != 'true'" 

I have two build definitions where each builds a different configuration. One of the builds was OK (Release) but the other (Nightly) had the problem that you describe. When I looked at the project file for the silverlight application using an XML editor, I saw that although there was a property group with a condition that evaulated to true for Release - there was none for Nightly.

I manually edited the file by taking a copy of the property group for Release and adjusted the condition and the OutputPath to suit the Nightly build. This resolved the issue.

I noticed afterwards that if I navigated to the Properties page for the Silverlight project in Visual Studio and swapped to the Nightly configuration using the dropdown in the toolbar, that a new PropertyGroup element was automatically generated for that configuration. This would probably also resolve the issue.

by : Scott Munrohttp://stackoverflow.com/users/81595




No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog