I am using a SharedAssemblyInfo file which seems to be a 'standard' technique:
http://blogs.msdn.com/jjameson/archive/2009/04/03/shared-assembly-info-in-visual-studio-projects.aspx
I put the SharedAssemblyInfo.cs file into my web application because with web site projects I cannnot 'add files as a link'.
But now I need to add a second web project to the solution and obviously the SharedAssemblyInfo file cannot be within both projects.
How do I get round this problem without having duplicate SharedAssemblyInfo files?
One way to solve this problem from within a web site as opposed to a web project is via your source control provider.
If you are using Visual Source Safe you can "share" the file to both projects (folders) and not branch. If you are using subversion 1.6 you can use a single file "externals" property. See this page for info.
In the case of Team Foundation Server, you can look at this codeplex article. I don't have any experience with TFS, but I think in the case of a SharedAssembly.cs the branch and merge solution would work fine.
This means you will have to check the file in in one location and check it out in the other location for the change to take effect. However, have the AssemblyInfo out of sync during the development process probably won't break anything.
Is it a web site or a a web project? With a web project the linked file should work fine... although personally I'd rather keep them separate and update them through my build script.
Related
I'm new to ASP.NET, and making a small update to a site that already exists. I am confused about the differences I see on the production server vs. the source code I've been given, and would appreciate any explanation or advice. Normally I would just continue reading and researching until I understood fully, but in this case I've been asked to make a small update to something ahead of my understanding. All I need to do is change one element in a form.
On the production site, there are files like \contact\survey.aspx; no .cs files exist in the directory alongside them, and there's no CodeFile directive. Instead, there are a multitude of DLL files corresponding to these pages, like bin\App_Web_survey.aspx.fdf9difs9.dll.
When I was given the source code of the site to edit, I see something different. The bin folder is entirely lacking in these DLL files corresponding to pages; instead, each aspx file has an aspx.cs file sitting next to it in its folder, a code-behind. Fair enough, I think; the site can run in its interpreted mode, like this, or compiled to DLLs.
Problem is, for the life of me I cannot work out how to do that; I've read dozens of pages on the MSDN library and gotten nowhere.
I am using Visual Studio Express 2013 for Web, and I've opened the source code folder as a website. When I run 'build', it succeeds, but no DLLs are made, not even in the Debug folder. This MSDN page has instructions for compiling web application projects, but the options don't correspond to the available options for me, so I'm guessing that either web application and web site are distinguished or that Visual Studio 2013 (which I also tried using and had no luck with) is distinguished from VS for Web. I'm at a loss.
tldr: Can anyone quickly sum up for me the process of compiling an ASP.NET website in a way that results in multiple DLL files in its bin directory?
You might need to use aspnet_compiler:
aspnet_compiler -p sourceCodeRoot -v / targetRoot
See How to: Precompile ASP.NET Web Sites for Deployment (MSDN).
I'm working with Visual Studio. There I have a solution with several web-projects (.net MVC 4). All of these web-projects use the same javascript-libs. Currently I copied the library into each project, but this can't be the final solution. What is the best approach to share those library (assets in general) between all of the projects? Just link them? Or is it possible to create a project and reference it in all projects?
Update
"Link" the javascript files from another project is not a possible solution as I would have to link thousands of files (one of the libraries I am using is ExtJs) what makes it impossible to build a project without freezing visual studio...
Possible solution
Currently I have a (Web) MVC Project called "Web" and a (Class Library) Project called "ClientScript" which contains all the JavaScript files which are shared between several Web Projects. As linking all the needed JavaScript files is not a possible solution (because it's a matter of thousands of files what causes visual studio to freeze) I copy all the needed JavaScript files to the individual Projects using the Build Events in each Web Project (Project -> Properties -> Build Events -> Post-build).
My Post-build command line in the Web Project looks like this:
start xcopy "$(SolutionDir)ClientScript\Frontend\*" "$(SolutionDir)Web\Scripts" /r /s /i /y /D /E
Every time you build your Web Project all the changed Javascript files get copied from the ClientScript Project to your Web Project.
While developing the Javascripts I run a small "filewatcher" tool which automatically copies a file from the ClientScript Project to every Web Project when it changes. This way I don't have to build the Web Project every time when I make a change to one of the Javascripts.
Anyone that stumbles across this question here in the future should know that there are now Shared Projects in Visual Studio to solve this problem. Universal Windows projects use them by default and you can create your own by downloading and installing the VS extension here: https://visualstudiogallery.msdn.microsoft.com/315c13a7-2787-4f57-bdf7-adae6ed54450
Note: At this time they can be picky about what type of project you try to add the shared reference. I created a JavaScript shared project to share js files between a Windows store js app and an MVC web app and it would not let me do that saying they had to be of the same language. (It supports C#, C++, or JavaScript).
Place the JS files in a single folder, likely above all others, and add them to the project but use the "Link" option. It's part of the drop down on the "OK" button in the "Add existing item..." dialog.
When you run every new ASP.NET MVC 4 project it's take a new port then other app have take.
I simply suggest you a simple thing.
run a project which contain all the pacakages. open them webmatrix and run them as localhost:80.
You need to set the port in settings section of your site in webmatrix. Now it will rechable at localhost now you can reference all the libraries from this packages.
Slightly older thread, but I have another way of doing a similar thing using Web Essentials, that handles the issue of not publishing correctly.
I have a shared folder outside of the projects that require the shared file, normally a 'common' project with other things in as well, but can be just a simple folder as suggested by Michael Perrenoud.
However instead of 'Add as Link' I have been creating a new bundle in the project that requires the shared js/css file, with the same name as the shared file, and then referencing that file in the shared folder using a relative reference location rather than the root based one it starts with.
To add a file from a shared folder in the root of the solution to the scripts folder use the following code in a new bundle file (*.bundle), changing the folder/file names as required.
<?xml version="1.0" encoding="utf-8"?>
<bundle xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://vswebessentials.com/schemas/v1/bundle.xsd">
<settings>
<minify>false</minify>
<runOnBuild>true</runOnBuild>
</settings>
<files>
<file>../../MySharedFolder/my-js-file.js</file>
</files>
</bundle>
Then every time you build it recreates the bundle with the latest version, this version is then also published as expected :)
You can even create a minified version if desired by changing 'minify' to true. Or better yet you can add them loads as a bundle too if you want, you have that flexibilty.
This is an older thread but due to complex business requirements these days applications are divided in to different modules or sub projects.Thus, brings us the need to share common resources like JavaScript files, themes and CSS style sheet files.
I personally feel that common files should be put in separate Asp .Net MVC 5 project which has following structure :ASP.NET MVC5 folder structure
Now the best part is you can separately manage the dependencies using Bower,NPM or Nuget package manager.
After you have organised all the files in this project host this project to your own CDN or may be on cloud. You can use Using CDN in Bundle Approach to get script or link references.
That will help you sharing common resources across all the projects.There us a short coming though if you have many developers on the team and if someone added incompatible version lib can affect all the apps.
SCENARIO: A developer at work has created an three-tier ASP.NET Web Application which plugs into the company website, however the rest of the site was done as an ASP.NET Website. For clearity, his portion used Web Application (compiled into single .dll) and the rest of the site is WebSite (seperate .dlls). I do not wish to recompile the website every time a change is made to a page.
QUESTION: Is it possible to convert a Web Application
to a Website without rewriting the entire application?
TRIED:
Created WebSite and copied & pasted files over
Changed'CodeBehind' to 'CodeFile'
Deleted .designer.cs from pages and controls
Checked References
Ok - assuming you have a backup, this is how I would tackle it:
Delete the csproj file
From within Windows Explorer, delete any designer.cs files
Still in Explorer, create an App_Code folder at the root of the site
Find any *.cs files that aren't code behinds (eg., .ascx.cs or .aspx.cs) and move them into the App_Code folder
Open in Visual Studio as Web Site project
Verify .NET FX version
Change CodeBehind= to CodeFile= in any .aspx or .ascx files
Readd any 3rd party references
There's some potential complications around Global.asax, ASHX handlers (need to be inline) and referencing pages and controls. You'll have to deal with those manually, I'm afraid - but if it's a smallish effort, it should be easily doable.
I have a C# application that uses several web services which were added to my project as web references. I want to know what files i should check into source control.
in my project there is a folder structure from my project directory that looks like this:
Project
Web References
WS
WS.wsdl
Reference.cs
Reference.map
...misc .datasource and .xsd files
Which of these files should i put in source control?
Thanks
Suggest keeping all those files under source control, but only for completeness for other developers using your project's source code, or having to perform a Checkout/Get Latest on any new machine (after your dev machine's hard drive dies, etc.).
Once Visual Studio builds the web reference, all those files are built and remain unchanged until you 'Refresh Web Reference'. If you modify them yourself, i.e. change a datatype, or remove an XML attribute (I've had to do that for some obscure runtime SOAP problem), then check those changes in as well.
If your nant script or visual studio solution or what have you rebuilds any particular files on each build, then don't check those in, as it'll just lead to confusion. Otherwise check it all in.
How to build and publish the ASP.NET web site(Microsoft Vishul Studio->File->New->Website) using Cruise Control.net.
Actually, ASP.NET Web site doesnot contain .csproj and .sln file.
Please Provide the solution and Suggestion for same.
Thanks in advance....
You can add your web site to an empty solution (giving you a .sln file), then call msbuild.exe using the exec task against the solution file, or use NAntContrib's msbuild task.
For deploying, since it's a website, you have two options: either copy the files directly to the target location, or first precompile with aspnet_compiler.exe, then copy. See this MSDN article on more info on precompiling.
Your build file will contain roughly the following tasks:
MsBuild
(Optional) aspnet_compile
Copy to destination location
Plug that into cruise control and you should be good to go (though I recommend separate build configurations for 1 and 2 vs 3).
please refer the msdn link: http://msdn.microsoft.com/en-us/library/1y1404zt(VS.80).aspx