Search code examples
silverlightreferencebuildxap

Check CopyLocal property of all references post/during build in multi project solution (Multi Xap)


I have a Silverlight solution that has multiple silverlight projects (Views) that all compile to their own .Xap file.

There is one "master" project that handles the dynamic downloading of the Xap files, which works pretty well.

But now I need to make sure that all the references are set to CopyLocal=false in all the View Projects. Only the "master" project can have CopyLocal=true.

This means that the Xap files generated by the Views stay rather small.

What I would like to do is check post or during the build process to see if any of the View projects have a reference with CopyLocal=true.

What would be a smart way of doing this? Using an external tool in the Post Build event? Or perhaps an addin for Visual Studio ? Or creating a macro in Visual Studio for this?

I have looked at using .extmap with assembly caching, but since you have to specify the assemblies in that, this does not solve my problem. I just need to know if there is a reference with the wrong setting and report that. Fixing it is not the question, that will still be done manually. It's just the notification I need.

Solution has 35 projects now, so dont want to check them all by hand every time.

I found a question similar to this one, but it lists msbuild as a possible solution. I would like to know if there is a way to do this using "code" (be it prebuilt in a tool/addin or otherwise)


Solution

  • I am using a different path now to do this. I have a base class that I can use to write unit tests that have access to the DTE2 object. This way I dont need an addin. This also works for Silverlight projects since the test class does not actually need access to the Silverlight projects, just being in the solution is enough to be able to iterate through the projects and check the references.