How to precompile ASP.NET 4.0 to a Single DLL with VS 2010 - visual-studio-2010

I recently upgraded from VS 2003 where I was working on a ASP.NET 2.0 website to VS 2010 where I have migrated to ASP.NET 4.0. So far it has been a big headache to get my site compiling with the new version. One problem was that my aspx.cs pages could not find the shared code libraries in my project. I solved this by moving my shared code to the App_Code folder (if there's a different/better way to do it please let me know).
Another issue that I am finding confusing is with pre-compilation. With VS 2003 I could click the build project button and it would precompile my site into a myweb.dll and myweb.pdb files. Now I'm having trouble doing the same in VS 2010. When I build the site in VS 2010 the dll is not created. I did manage to find an option to "Publish" the site which takes forever (like 2 minutes) and involves duplicating the site to another folder. This would have been acceptable but instead of making the single DLL file, it makes a bunch of files: App_code.compiled, app_code.dll, App_code.pdb, App_global.asax.compiled, App_global.asax.dll, App_global.asax.pdb, App_Web_lrpcway1.dll, App_Web_lrpcway1.compiled, App_Web_lrpcway1.pdb.
The application works - I can deploy it with all these files. However, I'd really like someone to explain what are the extra files and if there is a better way how to do it.
Thanks

This is the difference between a website and a web application.
You can convert your website to a web application to have it
behave more like you are used to.
The files in appCode are compiled when required to run and thus
does not provide dll.s in the bin/debug folder, but they should
be created when the application actually runs (but it is not
put in the same location).
Here is a nice write up about it Link

You can use the ASP.NET Merge Tool to combine all of the little DLLs into one big one.
http://msdn.microsoft.com/en-us/library/bb397866.aspx

Related

Create Visual Studio 2019 project from existing Azure Web App

I have a v7 Umbraco instance as a Web App on Azure but the machine the dev copy was on has been decommissioned and I need now to recreate the dev site in Visual Studio 2019, ideally cloning it from the live site in some way. I have created an empty project and, using the cloud explorer, downloaded the files from the app, but I am unclear whether I just copy them directly into the solution folder or into their own subfolder of the solution folder or whether simply copying them in will do the trick anyway as there's still the database to consider as well. I'm afraid I haven't used Visual Studio since creating this site three or so years ago and I seem to have forgotten most of what I did then anyway, so any help wpuld be greatly appreciated. The only advice I coud find via google was for older versions of VS and so not much help.
Recreating the original project from the live site is probably not going to be possible. It depends how and what you deployed to the live site.
It sounds like what you have is a working live site, but have lost access to the original source code. You should be able to copy the site and get it working elsewhere, but you're probably going to struggle to recreate the original development environment and amend the compiled elements of the website without access to the source code.
The Umbraco.com website has some great documentation on getting started and setting up Umbraco. Umbraco TV is great for getting up to speed quickly too. This should help explain the project structure. I suggest you create a blank Umbraco install to familiarise yourself with how Umbraco works(I wrote a post explaining how to do this with MS VS2015 here).
A typical deployment, using MS WebDeploy or FTP from Visual Studio, wouldn't deploy the project files or source-code for the compiled (.cs) elements of the website, these are usually kept as development files and checked in to source control.The live site probably only has the compiled versions of these file in the bin folder. The good news is the Razor template and view files(.cshtml) should be on the server.
However, if everything was uploaded (it happens) then you may have a chance, in which case you can download the files, potentially open the project and try to run the project locally on the development machine. There's no reason why you can't install an older version of MS Visual Studio alongside 2019 if there's an issue with that version. Although, I suspect this isn't an option since you felt the need to create a new empty project. If this is the case you might be able to add any project files to the the new empty project and attempt to recreate the project that way.
Regarding the database. You're going to need a copy or backup installed on a Microsoft SQL Server (unless you used MS SQL CE which is file based). You should be able to download a .bak file from the server if you're using Plesk or connect remotely using MS Management Studio if not, it depends on the host (Azure will allow access via MS Management Studio). Umbraco will need the connection string configured in it's web.config, the one you downloaded may be trying to connect to the live server so be careful.
Long shot ideas:
If you're really desperate you might be able to reverse engineer some of your compiled .dll using a tool like ILASM.exe but it's not going to be easy;
Perhaps you could reference the .dll in a the new project and it will all work auto-magically?! but I doubt this will work as there will be two application starting points and you'll probably get a runtime exception.

Visual Studio 2010 gets stuck with solution with MVC3 Razor and Azure

I've a solution with several .dll projects, an Asp.NET MVC3 Razor project and an Cloud project.
If I try to compile the solution with the Cloud project loaded, VS2010 gets stuck in "Buil started".
I have to forcefully close VS2010 killing the process and restart. Then the compiling works good once, the next time it will get stuck again.
If I unload the project and set the mvc project as start-up, everything works (but azure of course).
What could be the problem?
Cheers.
Was it by any chance an ASP.NET MVC project to which you added a CloudService project later on or did you start off with a CloudService from the very beginning?
I was in the former situation and I had no end of problems, like not being able to open property pages or deploying the application. It's not quite your issue, but the following article might help:
http://tomkrueger.wordpress.com/2010/07/27/azure-deployment-issue-after-upgrading-to-visual-studio-2010-and-net-4-0/
As I say, my problems started because I actually added an Azure project to an existing ASP.NET MVC solution and there were some unnecessary settings left over in the web.csproj file.
All I had to do was open web.csproj in notepad and remove all occurrences of the <PlatformTarget> element.
My MVC prjoject was x86 and of course Azure works on x64 only. Even though I had the platform target set up as AnyCPU somehow Azure couldn't quite get along with it.
Maybe cleaning up your project files helps as well.

can i use visual studio 2008 for a regular asp project

i have taken over an asp project from a friend and he was basically just using notepad++ to develop. I would like to use visual studio 2008 but there is no project file or solution file at this point, just a bunch of asp pages and some images, css
the other trick is that he will still be developing for a bit but doesn't want to use VS.
what is the best way to "upgrade" this so i can use VS ide features and he can still use notepad++ without any issue?
EDIT: Thanks for the responses. One additional request. We will ultimately be looking at migrating this to an ASP.net mvc site. Would that change any of the answers below or should i start from scratch when that happens in terms of vs projects solutions?
Yes. We are currently using it that way to support a legacy .asp application. We have a project in one of the solutions for the .asp pages.
edit:
In response to your edit I wouldn't see a need to change anything when migrating to MVC. You'll be adding new project(s) to your solution containing the .asp code. If anything, having it all in one place might make your life a little easier during the transition. Our ASP.net site(s) are in the same solution as the .asp project.
edit (part deux):
Using Notepad++ should present no issues. The edits would be to the .asp files (and .css, etc), not to the VS .proj file. I often use UE to edit the .asp files if I don't need to open the IDE. Assuming you're using a source repository of some sort...
Just create a blank solution (New Project > Other Project Types > Blank Solution) and then include all of the .asp files and any other relevant files.
You can just do File > Open > Web Site... and point VS at the folder containing the files. That should let you just edit the files. I say should as I don't have a classic ASP site to test this on.
When you start the MVC app, I'd start that one from scratch with a new project and then use your existing asp pages as starting points for your views.

VS automagically adding some undesired references to a WebSite project

We are facing a very weird situation using Visual Studio 2005:
There is a Web Site project we do have, and VS when compiling the project automagically adds some undesired references, like 'System.Data.Oracle' (we don't use Oracle at all, and never did) and things from asp.net 3.5 (the project is 2.0, we don't use in it anything related to the new version).
As a consequence of this, when putting the published site into the production server (configured for 2.0, without these strange dlls), the site doesn't work. Even if we remove these dependencies from Web.config file.
Have any of you ever seen something like this happening with your VS05?
Note: the bin folder doesn't have these dlls.
Save your sanity and stop using Web Site Projects. They were an abomination from the get go.
The conversion to Web Application projects is well worth the effort.
Are you using Visual Studio 2005 SP1? You should be. There are bug fixes in addition to the fact they added Web Application Projects back.
VS2005 isn't inventing these references. Something in your web site is using them.
Are you precompiling the site prior to deploying it?
We could resolve it!
The web site project references a project.
This project had all these references, and the web site used them.. Removing the undesired references resulted successful ;)

Visual Studio 2005: File->New->Project vs File->New->Web Site?

Say I want to create vb.net application in Visual studio 2005.
What is the difference between File->New->Project vs File->New->Web Site?
EDIT
I am aware that when using New->Project there are many more options available but if one wants to create just .net web application, would it make a any difference what option you choose?
Here's a good link about WAPs (web application projects) and the differences between WAPs and website projects.
In 2003, your only option (if I recall correctly) was the WAP. 2005 introduced the concept of website projects, where all your code is uploaded to the server and compiled into DLLs on first access. This allows you to easily change your code without having to compile and publish the dlls.
Not a lot of people liked this new way of doing it, so MS created an update to allow for 2003 style WAPs in 2005. 2008 retains both options.
The File->New->Web site option is the only way to create a website application (or, at least it is in 2k8). The only way to create a WAP is to do File->New Project->Web->...
If you create a project, all cs files in your project will be compiled into one DLL. Instead, if you choose to create a website, all your app_code will be compiled and cached on the fly.

Resources