I've just started investigating the Microsoft Ajax Minifer 4.0 for use with a Visual Studio 2008 Web Application I work on. It's proven easy enough to hook it into the .csproj file so it produced .min.js files for all scripts, however I'm stumped as to how to integrate this with the Web Setup project & Source Control.
Essentially what I want to do is have the resultant .min.js files included in the Web Setup project without having them included in Source Control because:
Having to check them out prior to the build being executing is a pain (the minifier cannot modify them if they're not checked out).
As they're created as a "build artifact" it just seems wrong to have them stored under source control.
The only option I've managed to come across so far is to explicitly include the .min.js files as part of the Setup project by right clicking on the Web Setup project and choosing "Add > File", and then having the relevant folder hierarchy duplicated in "File System on Target Machine" so that I can force the file to the correct location. This is neither elegant or simple/robust as:
It requires me to manually add every minified js file to the Web Setup project by hand
Maintain a copy of the relevant directory structure in both the Web Application project and the Web Setup project
Remember to add any new js files minified versions to the Web Setup project
Is there a better way of doing this?
The solution I eventually opted for was to include the minifier DLL in my project and create a handler (.ashx) that I've replaced all references to .js files with, so:
<script src="MyJsFile.js" type="text/javascript"></script>
Is replaced with
<script src="Minifier.ashx?file=MyJsFile.js" type="text/javascript"></script>
I have a configuration setting in my web.config file that allows me to determine whether script files are minifed or not.
Using the Microsoft Ajax Minifier with Source Control
The Microsoft Ajax Minifier generates
the minified JavaScript and CSS files
as the output of the build process.
For this reason, we recommend that you
handle the minified files in exactly
the same way as you would handle the
assemblies generated by the build
process. In particular, we recommend
that you do not include the minified
files in your Visual Studio project
and that you do not check the minified
files into source control.
If you include the minified files in
your project, and you use source
control, then you will encounter
problems. When files are checked out
of source control, they are checked
out with their read-only attributes
set. If you attempt to do a build, the
Microsoft Ajax Minifier will generate
an error when it attempts to write to
a read-only file.
source : Microsoft
From my understanding, this means do not add the -min files to the project, that's it. When IIS will build the app, it will create the files automatically. I think you must have Microsoft Minifier 4.0 to be installed on the web server tho.
Related
I have multiple web apps running on a server that all use a lot of the same css/image files. In order make everything more centralized i've taken all of the files out of the projects and wrote a small static file server in asp.net core with some gulp tasks to manage the css. The goal was to have it act like a cdn (with only one machine) and serve some other api functions, but to work locally without internet access.
I figured that if i included the visual studio project in the solutions for my other projects they would have access to the css/scss files for intellisense, which was not the case.
Is there some way that i can reference the files in visual studio so that i can get auto completion in the apps' view files?
I solved this problem by creating a symbolic link that included the assets in the desired project.
I was hoping for some advice on the correct approach to get my asp.net vb.net web application project completely ready for deployment. I recognise that I switch to release mode and compile. So I have my server-side code successfully compiling into a .dll file in the BIN folder, this is exactly what I want.
The issue where I am unclear is with the aspx.vb files and the aspx.designer.vb files that are attached to the .aspx files, I am using VS2010. I want to remove all of these from my project so that any of our potential clients have no direct access whatsoever to any of the server side code.
I have decompiled the .dll file and can see that it is all in there so I am fairly certain if I remove the code behind files the program will run without any difficulties. As I have never done this before I was hoping for some basic tips. Is this the correct approach to take? If so is there a standard good approach for removing the aspx.designer.vb files and the aspx.vb files from a given project within Visual Studio, or is it a case of manually taking them out of the release mode?
Thank you for any tips.
The code behind files are compiled into the dll in a web application so you don't need to deploy the .vb files (nor do you want to).
The dll is not obfuscated by default so anyone could decompile it to see your source however. There are free and non-free obfuscators available but that is outside the scope of this question really.
The easiest way to deploy is to use visual studio to do this for you (I think you might need pro version or above)
You can set up your own test web server locally and deploy to that first to see which files are in there.
I am working on a project using Web Essentials to bundle and minify script files.
It works perfectly well and Web Essentials run when I save changes the to script files. We are currently several developers on the project and we face a problem every time we get changes from our source control (TFS). Changes to the script files does not trigger Web Essentials to run, unless we manually edit and save a script file. Since we have a few projects, we currently have to do this for every project.
Is it possible to trigger Web Essentials to run on builds (build events)?
I noticed that the bundle files include an attribute called 'runOnBuild'. This is set to true, but does not seem to do the trick.
I am also open for suggestions on alternative approaches (trigger via TypeScript compiler, etc.)
In the source code of Web Essentials I found out that Web Essentials uses AjaxMin. It is possible to create a build task for AjaxMin according to this thread: AjaxMin Build Task to minify all js to separate folder
i have publish my website. using publish website in vs 2008.
Now i want to update a single file.
So do i need to recompile the whole web-site and upload it to the server again, or i will just publish this single file and upload it to the server.
if i can compile a single file then how to do it, also how to update it to the server?
Depends on whether your web project is a web application project or web site project. If its a web site, then you can just copy your updated file to the server and ASP.NET will recompile it for you.
If your web project is a web application project, and you made changes to the code behind, you'll need to recompile the project, and redeploy the DLL.
Also, if you're just updating an ASPX page (not the code behind, ASPX.cs), you should be able to deploy it without compiling.
If you frequently update your website, I recommend to Check
Use fixed naming and single page assemblies checkbox.
This will generate seperate DLL for each code behind page,
Although you have to compile full project but you can upload only relevant file.
This is very helpful in case if many people are working in single project, everybody can change in their respective .cs file and publish their .cs file's DLL , this will not affect other people's DLL and thus functionlity will not break, unless DLL's or codebehind clashes with each other.
I'm using a Web Deployment Project in Visual Studio 2008 in order to prepare my ASP.NET application (ASP.NET web application, not ASP.NET web site) for being copied to several servers. I have to copy the files on local staging servers, on different servers via FTP and sometimes I have to fetch them from customers' servers.
So, it would be nice to have all files for deployment in a compact form without the necessity of doing a lot of comparing between source and destination. Web deployment projects have this nice feature: compile all your aspx and ascx files into a single (additional) assembly.
I somehow found out how to get rid of aspx placeholder files on the server, now I'd like to know if there is a (maybe self-made) way to get rid of these .compiled files.
From Rick Strahl's blog:
The .Compiled file is a marker file
for each page and control in the Web
site and identifies the class used
inside of the assembly. These files
are not optional as they map the ASPX
pages to the appropriate precompiled
classes in the precompiled assemblies.
If you remove the .Compiled file, the
page that it maps will not be able to
execute and you get a nasty execution
error.
Anybody out there with a creative idea, maybe using a module/handler which intercepts the check against the .compiled files in the bin folder?
The .compile file comes from pre-compiling on deployment. So you basically have 3 options:
Keep the .compiled file
Don't pre-compile and deploy source code
Turn this in to a Web Application instead of a Web Site and compile as an assembly
I have run in to the same problem myself. I actually choose #1 in most cases when dealing with deployment of Web Sites, but on the rare occasion when I know I am going to have to maintain the site for an extended period of time, I take the time to upgrade it to a Web Application.
I don't like the .compiled files either, but nobody gets hurt if they're there. So why bother?
You might want to take a look at Virtual Path Providers (KB how to here) in ASP.NET.
Credit for this suggestion must go to Cheeso and his self answered question here:
Can I get “WAR file” type deployment with ASP.NET?
I don't know about the .compiled files, but you could set up your servers to update their files with subversion instead of manually copying the files when you compile.
So you would compile the files using the Web deployment project (not into a single assembly), put them in a repository you created for this purpose, and on each server, just do an svn update to fetch and compare the files automatically.
I know it's not what you asked for directly, but it may be a path to explore.
Add "Exclude Filter" to your deployment project:
In the Deployment Project.
Right Click on Content Files.
Click on "Exclude Filter".
Add "*.Compiled"
click OK.
and thats it.
I remember at the days when I cant do Web Application with VWD Express, I use nant script to compile the project into a single dll and deploy, that would work (so I dont need the full VS to do dll deployment too), so if you really don't want to mess your project to Web Application, maybe this is a path to check too.
You can get rid of the .compiled files by using the aspnet_merge tool with the -r option.
Removes the .compiled files for the main code assembly (code in the App_Code folder). Do not use this option if your application contains an explicit type reference to the main code assembly.
If you publish your code as updateable (in publish settings) these files are generated. Uncheck that value and republish. This is an old question I know, but no answers are clearly defined for this here.