I have a silverlight project arranged as follows:
- Examples
- Silverlight
- Bin
- Debug
- Bin
- ExampleCode
- {Multiple Sub directories}
- Silverlight
- Silverlight.Web
- Bin
- Debug
- ClientBin
- Silverlight.Web.xap
- ClientBin
- Debug
- Bin
The code under {Multiple Sub Directories} is included in the silverlight DLL and compiled, however I also want to include these files as "Content" in the xap file. Think about demo applications for .NET controls that show you a demo but also the C#/xaml code to achieve it. This is what I'm trying to do.
- I cannot select include as content as they are already included as compile
- I cannot include the files twice and compile one and content the other as VS2010 won't let you.
I would like to include all the files/folders under the Examples/Silverlight/ExampleCode folder in the output xap file. To achieve this I attempted a post-build event on the Silverlight.Web project. The syntax is below:
"$(SolutionDir)..\Lib\7Zip\7z.exe" a -tzip
"$(ProjectDir)ClientBin\Silverlight.Web.xap"
"$(SolutionDir)Examples\Silverlight\Bin\Debug\ExampleCode"
Now if I execute this in a console window it works perfectly. The xap file is updated. However if I execute it from the post-build event in Silverlight.Web nothing happens (no failure, just nothing).
I assume that the post-build event is fired before the xap file is created.
Does anyone know how I can run a MSbuild task or command line post-build event with arguments after the xap file is copied to ClientBin?
You can work around this by adding your files to
XapFilesInputCollection
in anAfterCompile
target of your Silverlight project. Note however that including a bin folder directly in the project may result with an access denied error when compiling in Visual Studio.