Daniel Williams
Daniel Williams

Reputation: 9304

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

Upvotes: 9

Views: 3418

Answers (8)

M. Tovbin
M. Tovbin

Reputation: 547

After carefully reviewing the configuration that was being built for CI, I found that one of the projects being referenced by my web project was set up to build with a wrong configuration. My CI build was set up to build for Staging (Any CPU) and one of my .projects that was being referenced by the Web project was set up to build using Release configuration. Once I updated the Configuration to be Staging, the CI build completed successfully

Upvotes: 0

Andrija
Andrija

Reputation: 14473

I had the same problem. I was making build script, running msbuild on solution. I was building solution in "Test" configuration, but web project that referenced Silverlight projects kept looking in target bin\Release folder for binaries. I tried re-adding Silverlight projects, problem was still there.

It turned out problem was to specify Platform in msbuild arguments. Solution configuration "Test|AnyCPU" and "Test|MixedPlatform" is no same. You will find that both Configuration and Platform has to be equal to same pair defined in project file. I don't know what Platform was msbuild taking by default, but I know it jumped to Release folder instead.

Anyway, I added /p:Platform="Any CPU" to msbuild arguments.

Upvotes: 0

Rick Glos
Rick Glos

Reputation: 2552

To further confuse the matter, I added 2 new projects to our existing solution (a new library and it's associated test project) and the CI build failed with the no silverlight project specified for silverlight output error, which was succeeding 2 days prior. The 2 new projects didn't have the configuration being used by the other projects.

Adding the missing configuration to the 2 new projects via the Solution Configuration Manager fixed it.

Why this would affect the Silverlight projects, which have no relation to these 2 new projects, I have no idea.

Upvotes: 0

Scott Munro
Scott Munro

Reputation: 13576

I seemed to be getting duplicate xap file names being generated within the CopySilverlightApplications task which were causing this error. I was able to resolve this issue by making the modification below to the following file. Note the introduction of a new ItemGroup and the reference to it from the SourceFiles attribute in the CopyFilesToFolders Task.

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

<ItemGroup>
    <_UniqueSilverlightXapFiles Include="%(_SilverlightXapFiles.FullPath)" />
</ItemGroup>

<!--Copy the outputs to the target folder-->
<CopyFilesToFolders SourceFiles="@(_UniqueSilverlightXapFiles)" 
                    SilverlightApplications="@(_SilverlightApplications)" 
                    ConfigName="$(Configuration)"  
                    Condition="'@(_SilverlightXapFiles)' != ''">
  <Output TaskParameter="DestinationFiles" ItemName="_WebApplicationSilverlightXapFiles" />      
</CopyFilesToFolders>

Upvotes: 0

Erik Oveg&#229;rd
Erik Oveg&#229;rd

Reputation: 348

I had the same problem. The project built just fine in Debug and Release configuration but I got "No Silverlight project specified for Silverlight output" in the web-project. I also noticed that it was trying to copy the .xap-files from ./bin/Release/ instead of ./bin/Production/.

After removing all Silverlight Applications (tab in project Properties) from the web-project and adding the ClientBin folder as the output path (suggested here) I got a better error message. The problem was that some projects referenced by the web-project were missing the selected configuration. After adding the configuration I could add the Silverlight Applications to the web project again and return the Output path to bin/$(Configuration)/ and still build the solution.

Upvotes: 1

Scott Munro
Scott Munro

Reputation: 13576

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.

Upvotes: 1

Edward
Edward

Reputation: 8596

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
}

Upvotes: 6

MerickOWA
MerickOWA

Reputation: 7592

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.

Upvotes: 9

Related Questions