I am creating an install for an MVC4 site that will be installed at customer sites. I do not want the javascript to exist on disk "not minified". Is there a way to use the existing bundling framework to bundle and minify on publish? Right now the files are served minified but are stored in their original readable format. Prior to MVC4 I was using a build script to do this, I hope to not have to go back to that. Is this possible?
I believe that this tool will do what you want; for what you're trying to do you'll probably want to use the MSBUILD-related functionality:
http://yuicompressor.codeplex.com/
Related
I want to start playing with Aurelia and MVC 6 Web API with Visual Studio 2015 RC, and I'm using OdeToCode's blog post as a starting point.
I understand the idea behind the new wwwroot folder, but I'm basically confused as to what should or shouldn't put in there.
My initial thought would to install all jspm packages as well as the actual JavaScript source files outside the wwwroot folder, and then copy with gulp everything that's necessary for running while developing or bundle and copy when deploying.
It would look something like this:
But then again, should I place index.html also in the src folder? and config.js? Or am I actually making my life difficult for myself and should just develop from within the wwwroot folder?
It's the jspm packages that confuse me; it feels wrong to have such a large amount of JavaScript files in the wwwroot when I plan on bundling and minifying anyway.
In short: What would be the preferred folder structure for an Aurelia ASP.NET 5 app in Visual Studio 2015?
I spent quite some time on this and finally settled on:
ApplicationName
src
Api
In here I have an ASP.NET 5 project that provides the api to be consumed by the Aurelia app. You will likely need to turn on CORS to avoid errors.
Client.Web
In here I started with the Aurelia skeleton navigation app. We changed the dist folder to wwwroot. The jspm_packages folder sits outside the wwwroot and the gulp tasks that come with the skeleton navigation app take care of all the copying to wwwroot as needed.
This approch gave me the following benefits:
Clean separation of the api and the client code.
Option to deploy the api and client separately.
Ability to leverage all of the gulp tasks that come with the skeleton navigation app
Clear place to switch over to the Javascript file naming conventions (camelCase)
The drawbacks of this approach:
Starting the full app is more difficult. Currently, I have to click "Play" in Visual Studio to start the api, then I have to start gulp watch. This is not too big of a deal because you can mostly leave gulp watch running the entire time you develop.
I'm using YUI Compressor as a MsBuild Task on my Azure project. It works well on locally but when I try to publish it I cannot insert minified packages to my azure application package. Although I have tried a lot of things about package modifying on my .csproj file I couldn't work it out. How can I do this?
Edit:
My project is not a MVC or Webforms application. Just HTML and Javascript inside of an ASP.NET project. My problem is not minification. It is just placing minified external files in Azure Package when publishing it but if there is any other method that solves this azure problem, I can change YUI Compressor with ajaxmin or google closure... doesn't matter.
I don't think modifying the service package is supported (you are also modifying the manifest). That's why I would look at it from an other perspective. I'm assuming you have such a setup:
Solution
Empty ASP.NET Project
Index.html
App.js
Now, after you compile (and the MSBuild task runs) you'll have something like this:
Solution
Empty ASP.NET Project
Index.html
App.js
App.min.js (not included in the project, but available on the file system)
Now, buy simply including the App.min.js file in the project, it will be included in the service package when packaging or publishing your application. And besides that, the MSBuild tasks runs each time you compile, meaning the file will be updated before each time the application is packaged.
As you haven't specified about about whether it is WebForms or MVC, I would like to point out the out of the box support for the bundling and minification in ASP.net MVC4. Scott Gu has explained it the MVC4 preview demo.
You can also tweek it to work a way for that in ASP.net MVC3 too. Once this is achieved, you can achieve that in Azure as well.
Additional Articles :
ASP.NET MVC4 bundling in ASP.NET MVC3
New in ASP.NET MVC4: Bundling and Minification
I need to compile my web site, is it possible without converting to a web project first?
I think he wants to "protect" his code for any deployment.
If this is a .Net project you can try hide some code using codebehind components in ASP.NET.
Here is an small tutorial about it:
http://asp.net-tutorials.com/basics/code-behind/
For older projects you may have to build a cgi binary application, but as already mentioned here, add some more details to specify your problem.
I think you want a VS Web Deployment project. This exists as a separate project in your solution but can compile and copy the existing web project to a different directory.
There's a reasonable write-up of it on this blog with step-by-step instructions. You'll need to download and install the new project type separately though (2008, 2010)
Has anyone had success making an msbuild file that will publish a Web Application, not the old 2.0 web site but a Web Application?
This is not what I am looking for:
<MSBuild Projects="eRx.Web.SecureSiteShell.csproj" Properties="Configuration=Debug;OutDir=$(OutputFolder)\$(OutputWeb)\bin\;WebProjectOutputDir=$(OutputFolder)\$(OutputWeb)\" Targets="ResolveReferences;_CopyWebApplication" />
I tried simply using 'targets:Publish' but I get : Skipping unpublishable project.
Apparently this just isn't possible. My first hint was getting absolutely no response from this site.
I began to look into making a web setup project but was unsatisfied at having to edit the installation dialogues to get a custom installation folder. All I really need is something that will copy the published output of a Web Application (not Web Site you 2.0 peeps).
I think I have cheated the system by creating a simple Windows Setup program. Surprisingly I am able to include the primary output of my web application which satisfies my need. I DO have to manually add each projects debug symbols if I want them so the process can be lengthly but doable.
Like I said, not completely satisfied because I wanted to get the files in a nice deploy folder for my QA group to work with but feeding them an MSI has its advantages I suppose.
I leave this for anyone to comment on. I still can't believe I can't do this from msBuild or any other tool.
I am pretty new to msbuild and aspnet_compiler.
I am using aspnet_compiler to compile web application project. Now I just saw the MSBuild.exe and noticed that its builds my website into the /mywebsite/precompiledWeb folder. Now why do I need to use MSBuild.exe? Can't I directly use the aspnet_compiler to see if my website can be built properly?
(Not sure if I explained it very well).
msbuild.exe is usually used to build projects and its dependencies. When you have a web application project with a project file, vs can use this to build not only your web project but all the dependencies involved. This would only build your source code files, not the markup files (.aspx,.ascx,.etc).
aspnet_compiler is meant to build a web site project that doesn't have a project file. This said, you can also use it to make sure your markup files are also built for your web application project.
You are correct you can manually invoke the aspnet_compiler.exe tool. But better would be to use Web Deployment Projects to help you do this.