How to build silverlight website & create XAP's using script? - asp.net

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 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 when i was buiding solution through visual studio, But
I want same thing through using nant script when i am used nant script that time all project in the solution are build but recenty added silverlight website do not create XAP's in ClientBin dierctory.
I m using following script :-
target name="build" description="compiles the source code">
exec program="${framework::get-framework-directory(framework::get-target-framework())}
\msbuild.exe" commandline="MY.sln" workingdir="ProjectFolder" />
what are the ways ??

You could reverse-engineer the MsBuild scripts used to build Silverlight apps and .Xap files, the files will be located in:
C:\Program Files (x86)\MSBuild\Microsoft\Silverlight\v3.0

Your msbuild compilation should be creating the XAP file in the Bin\Debug folder of the silverlight project. You can simply use the Nant copy task to move it to the Web project's ClientBin folder.

Related

Publish asp.net 3.5 website to local folder using MSBuild

I have a solution with multiple class libraries and a website (not a web application) in framework 3.5 VS 2008.
I would like to create a script/batch file to automate the publishing of the website to a given folder location(not to IIS).
I tried googling regarding this but everywhere they are refering to a .csproj file for the website. In my solution I do not have any such file for the website.
I do not want to use any add ons / other tools for automated builds right now.
Please suggest an approach using MSBuild or any other inbuilt asp.net tool.

Why 'publish' website produces bin with one dll and build script produces bin with lots of dlls

I have made a script that uses the following command...
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe"
"C:\Repositories\Software\trunk\main\upload\UploadWebsite.csproj"
/p:Configuration=Release
This makes a website pre-compiled the bin directory has lots of dlls in it and tons of .compiled files...
However when I 'right click' on the project in visual studio I am able to 'publish' the website to a folder and this creates a pre-compiled website with only one dll. This is the preferable option im just wondering what the difference between the two is....?
The problem is that for a Website project, the publish feature of Visual Studio compiles everything into one dll, while the normal build operation compiles every page into a seperate DLL.
Maybe these articles can help:
Publishing Web Application with MsBuild
How to publish a web site with MSBuild

build ASP.Net default web site error

I am using VSTS 2008 and I am using Create new ASP.Net web site and using default settings/automatically generated files.
My questions are,
How to use command line script (msbuild) to build the ASP.Net web site automatically?
I want to build the web site into a DLL which could be easily copied to target IIS server later.
Any samples or quick answer how to do these tasks in msbuild?
EDIT1: There is no sln and csproj file in the web site folder. Here is the link.
http://tinypic.com/view.php?pic=dra5jp&s=5
Here is how I create in VSTS 2008.
http://i40.tinypic.com/208zfxv.jpg
I use VS.NET 2005 and using this command to build my asp.net web application in release mode :
cd "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\"
MSBuild "C:\Projects\MyProject.csproj" /t:Rebuild /p:Configuration=Release /verbosity:quiet /p:WarningLevel=0
"Web Applications" have .csproj files, "Web Sites" do not. http://damieng.com/blog/2008/02/07/web-site-vs-web-application
You want to compile it with aspnet_compiler.exe in the bin directory C:\windows\framework\version
http://msdn.microsoft.com/en-us/library/ms178466.aspx
Easier way is to use deployment projects or the "Publish Web Site" command in Visual Studio. (Right Click on website)
http://weblogs.asp.net/scottgu/archive/2008/01/28/vs-2008-web-deployment-project-support-released.aspx

How to get the Silverlight XAP copied to the clientbin on build

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?
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.
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.
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.
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.

How do I compile an ASP.NET website into a single DLL file?

I have finally finished my web site. I published it, and I was surprised at the results. Although the App_Code compiled into a single DLL file, every page's code behind compiled into its own DLL file. How do I make it so that it is one DLL file?
Also, is it possible to compile everything (SubSonic, AJAX, etc.) into that same single DLL file?
You might prefer to use the web application project style for that.
You can use ILMerge to merge assemblies into one.
The way we do it is by adding a deployment project to our site:
http://msdn.microsoft.com/en-us/asp.net/aa336619.aspx
To accomplish this you will have to covert your project into a Web Application Project (Supported in Visual Studio 2005 SP1 and Visual Studio 2008).
The process of converting is not that hard, but you will need to move everything out of the app_code folder, as WAP (Web Application Projects) projects do not have code inside app_code.
Once you do this, everything inside your project is compiled into a single DLL file, any external assemblies are still contained in their own DLL files though, but there are options around that as well.
We use build scripts for our websites and run the aspnet_merge.exe from the command line. Here's the MSDN page: http://msdn.microsoft.com/en-us/library/bb397866.aspx

Resources