views:

788

answers:

3

Hi all

I have a Silverlight 3 project which compiles and runs fine when compiled on a development machine. On our TFS environment with Silverlight 3 and the Silverlight 3 SDK installed, I get the following error:

C:\Users\tfsservice\AppData\Local\Temp\\Release\Sources\Source\Trunk\Themes\ UserDatesStyles.xaml(63,47,63,47): error : The property 'Command' does not exist on the type 'Button' in the XML namespace 'clr-namespace:Mvvm.Input;assembly=Mvvm'.

More information: Command is an attached property on Button that is part of the Mvvm assembly in the Mvvm.Input namespace.

Am I missing something on my TFS server? I would have thought that all I would require is the SDK. If I edit this project and change the ValidateXAML element to false, the TFS server does compile properly. However, this is obviously not the ideal situation.

Here is the XAML that causes it:

<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:commands="clr-namespace:MvvmFramework.Input;assembly=MvvmFramework"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d">
    <Style x:Key="UserDatesStyle" TargetType="controls:UserDates">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="controls:UserDates">
                    <Grid Height="600" Width="800" d:DesignWidth="800" d:DesignHeight="600">
                        <Button Content="Previous" 
      commands:CommandBinder.Command="{Binding PreviousPageCommand}" 
                                Margin="0,0,10,0" 
                                Style="{StaticResource PrevBtn}" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
+1  A: 

I am not very familar with Silverlight development, but I do have the latest Visual Studio 2008 SP1, Silverlight 3 Runtime, SDK, Tools and Toolkit installed and I do not have an Mvvm.dll anywhere on my machine.

This looks like a 3rd party dll, yours or someone elses, that is missing from the build server.

Where is the file referenced on the development machine that successfully builds?

It may be that will give a clue to the missing piece of the stack that needs to be installed, or added to a shared location that can be referenced from the project when pulled down on the build server.

Zach Bonham
Yes it is a custom DLL. That is the problem. My dll is referenced and WORKS but does not build in TFS.
Ray Booysen
It certainly sounds like a dependency issue, maybe not specifically the MVVM.dll, but related to the MVVM.dll. It might be worth opening the MVVM.dll using Reflector on the build server and review its references. If Reflector can't resolve the dependency, it will let you know. Then that missing dependency, if any, is what needs to be installed, or referenced as a shared assembly in a shared location.
Zach Bonham
You've misunderstood. There is nothing wrong with the code, the application compiles and works fine on machines other than the build server.
Graeme Bradbury
I don't think he's misunderstood. It looks like your build server doesn't have access to that assembly. Is it precompiled or referenced as a project in your solution? If it's precompiled, is the DLL checked into source control? If it's precompiled and checked into source control is it in the same branch in your source control tree that is downloaded when the build runs?
Anderson Imes
Also, if you are referencing this Mvvm.dll from the GAC on your local machines, it would need to be GAC'd on the build server as well.
Anderson Imes
Ray, please post the errors section from your build log (everything after the words "Build FAILED". If you scroll way to the bottom, this will be the last few dozen lines or so.
Jerry Bullard
A: 

I have the same problem.

The Build is fine in Visual Studio but within Team Build there are errors. I know the Xaml is valid and the Assembly the type is coming from is properly referenced and built before project with the problematic xaml validation.

I believe this is a bug with the ValidateXaml target in the C:\Program Files\MSBuild\Microsoft\Silverlight\v3.0\Microsoft.Silverlight.Common.targets file or maybe the target is being called too early before everything is fully built.

I dunno.

I ended up changing the property in the csproj file to false and although Team Build reports a ton of Validation errors it compiles and runs fine.

Robert Kozak
+1  A: 

I managed to fix it on our solution... drove me nuts, we could get away with disabling xaml validation on the build server by passing /property:ValidateXaml=false to our build script. However it became a showstopper when we couldn’t build the project in blend. Blend doesn’t follow the same build process as VS, perhaps it just shells out to msbuild.

I added this to Microsoft.Silverlight.Common.targets just above the call to ValidateXaml:

    <Message Text="--------------- Start: Build Hack -------------------------" />
    <Message Text="ReferenceAssemblies: @(ReferencePath);@(InferredReference->'$(TargetFrameworkDirectory)\%(Identity)')" />
    <Message Text="ProjectAssemblies: @(BuiltProjectOutputGroupKeyOutput)" />
    <Message Text="SilverlightPages: @(Page)" />
    <Message Text="SilverlightApplications: @(ApplicationDefinition)" />
    <Message Text="ProjectPath: $(MSBuildProjectFullPath)" />
    <Message Text="AssemblyName: $(AssemblyName)" />
    <Message Text="OutputPath: $(IntermediateOutputPath)" />
    <Message Text="ShouldThrow: $(ThrowErrorsInValidation)" />
    <Message Text="TargetFrameworkDirectory: $(TargetFrameworkDirectory)" />
    <Message Text="TargetFrameworkSDKDirectory: $(TargetFrameworkSDKDirectory)" />
    <Message Text="--------------- End: Build Hack -------------------------" />

... it looked like the ReferenceAssemblies were not correctly pulling in the correct references to the other silverlight projects, ValidateXaml seems to create an app domain and load in all those references to check if the types exist.... Anyway cut a long story short ValidateXaml wasnt getting passed the correct references as noted in visual studio thus we suspect it failed.

We believed it to be something corrupt in our configuration, we fixed it in the end by simply removing all offending projects getting the build to run from the cmd line (i.e. msbuild.exe) and VS, then adding each project back. After it was all done we noticed some differences in the .sln, the problem code had a strange 'postProject' ProjectSection under one of our Silverlight projects.... but its largely one of those 'you'll never really know', the .csproj’s seemed to be the same.

Remove the projects and add them back, worked for us. We suspect a corrupt solution file.

Keith
Awesome, would mark yours as the answer, but SO won't let me for some reason.
Ray Booysen
no probs, welcome to Lab49 BTY :)
Keith
Ha, thanks Keith. :)
Ray Booysen