How to get the Silverlight XAP copied to the clientbin on build
Asked Answered
U

4

24

I am just getting started with Silverlight and have recently added a Silverlight project to an established solution. In this particular scenario my solution included an existing ASP.NET web site (not application) which Visual Studio kindly offered to integrated my Silverlight application into, which I accepted.

So everything is fine and all, and the Silverlight XAP is being copied to the web site's ClientBin directory. Now I have decided to start a new ASP.NET MVC web application that will eventually replace the older (non-MVC) web site. But I cannot for the life of me figure out what Visual Studio modified to get the XAP to automatically appear in the web site's ClientBin on build, so that I can reproduce that on my MVC site.

So my question is essentially, what are the manually steps for getting Visual Studio to autocopy a Silverlight application's XAP to a newly added ASP.NET MVC web application?

Unsuspected answered 16/10, 2008 at 2:56 Comment(0)
D
16

The copying of the XAP to the ClientBin is a MSBuild task. If you're using a standard ASP.NET project template it can be found under the Silverlight Link section.

For everything else you might be able to figure out the name of the MSBuild task and add it to your ASP.NET MVC project. The easier solution would probably be to use a custom post-build event on the APS.NET project to copy the file.

There is no "magic" happening, oter than copying the XAP file from the BIN directory of your Silverlight project to the ClientBin of your web application. It doesn't even have to live inside the ClientBin directory - you can copy it to any directory, or the root of your site.

Update: The recently released Beta 1 of ASP.NET MVC includes support for Silverlight projects, so you can link it to your ASP.NET MVC application the same way you do for regular ASP.NET applications.

Daisydaitzman answered 16/10, 2008 at 4:19 Comment(0)
F
35

You can do this through the properties of your web project. The Silverlight tools for visual studio add a new tab to the properties of web projects named "Silverlight Links".

Add a reference to your Silverlight project here, with the folder where you want it, and visual studio will make the copy for you.

Ferroelectric answered 16/10, 2008 at 9:4 Comment(1)
If you do not have the "Silverlight Links" tab in your web project; install the Silverlight SDKCelloidin
D
16

The copying of the XAP to the ClientBin is a MSBuild task. If you're using a standard ASP.NET project template it can be found under the Silverlight Link section.

For everything else you might be able to figure out the name of the MSBuild task and add it to your ASP.NET MVC project. The easier solution would probably be to use a custom post-build event on the APS.NET project to copy the file.

There is no "magic" happening, oter than copying the XAP file from the BIN directory of your Silverlight project to the ClientBin of your web application. It doesn't even have to live inside the ClientBin directory - you can copy it to any directory, or the root of your site.

Update: The recently released Beta 1 of ASP.NET MVC includes support for Silverlight projects, so you can link it to your ASP.NET MVC application the same way you do for regular ASP.NET applications.

Daisydaitzman answered 16/10, 2008 at 4:19 Comment(0)
G
4

Go to the property pages of your Silverlight application, Choose Build Events Tab, Enter following line in Post-Build events command line:

copy $(TargetDir)*.xap $(SolutionDir)<youar web solution folder name such as app.web>\ClientBin

Now onwards, on each successful build, the xap file will be copied automatically.

Great answered 10/7, 2010 at 9:59 Comment(0)
I
2

This is a somewhat older post so it probably has changed... in my Visual Studio under the web project there is a tab called "Silverlight Applications". There is an add button there for existing projects that you import into the solution and you can add them and choose to place the xap in the ClientBin or anywhere else. Not sure if you have to have the SDK installed to have this tab. I have it installed so you may have to. I don't do MVC, so it may be different for MVC projects, I don't know.

Interact answered 22/9, 2011 at 13:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.