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
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.
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
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With