Asp.net MVC 4 bundling generation of .min files - asp.net-mvc

I use bundling for some .css files in my solution. I have noticed that when I run the solution in "release" mode (with debug="false" in web.config) a .min file is created, if not existing, for each file included in the bundles.
I have made some modifications in Bootstrap.css, and the only way to see these modifications in the minified file (bootstrap.min.css) is to remove it and then to run the solution with debug = "false".
Is there another way in Visual Studio to automatically regenerate the .min files?
EDIT: I was wrong, running the solution with debug = "false" does not automatically create a .min file if it does not exist. So the question is: how can I update the .min files in Visual Studio?

Have a look at http://vswebessentials.com/. It is a VS Extension for helping with web development.
It will minify your css and js files. Bundling won't re-minify already minified files so you should be OK.

I'm using Mads Kristensens Bundler & Minifier and think it is very easy to install and use.
The bundleconfig.json file can be configured to automatically bundle and minify on build in Visual Studio or you can minify manually by right clicking the css file.
More info and download link:
https://visualstudiogallery.msdn.microsoft.com/9ec27da7-e24b-4d56-8064-fd7e88ac1c40

Related

Does the Grails "war" command minify JavaScript files?

I have a Grails application building in an AWS CodePipeline. We recently upgraded from Grails 4 to Grails 5 and now one of the third-party JavaScript packages we use is having a problem because it's being minified somewhere in the build process, but the minification process is not properly renaming a particular variable in all parts of the js file. I'd like to switch the minify option in our build process to whitespace only in order to prevent the js variable names from being renamed/shortened. In my local builds, I use the asset-pipeline plugin in build.gradle to minify the js files and I set the optimization level to whitespace only...which works great...but I'm not sure where/how to do that in the AWS CodePipeline.
In the buildspec.yml file being used in the codepipeline, we are simply installing Grails 5 and then issuing the following command: /root/.sdkman/candidates/grails/current/bin/grails war -Dgrails.env=$GRAILS_ENVIRONMENT
Someone on the team thought the Grails war command might be responsible for the js minification, but I haven't been able to find anything. Hence my question here. Any help would be appreciated.
I figured it out. The minification does occur during the WAR creation. I had to add the following code to the application.groovy file in order to minify whitespace only.
grails.assets.minifyOptions = [
optimizationLevel: 'WHITESPACE_ONLY' //SIMPLE, ADVANCED or WHITESPACE_ONLY
]
I also had to modify the problematic js file by adding a comment to it in order to force that file to be re-compiled.
https://bertramdev.github.io/grails-asset-pipeline/guide/usage.html

Include files to build generated by angular-cli before build in asp.net mvc

I am struggling with a issue for files generated by nodejs needed to be included in build. It works well in local development but when i want to publish it then it won't include files fron dist folder to build and app will not have a dist folder. Can any one help on this?
Note:- files are created each time has different name so i cannot select and include them. I am using visual studio 2017. I hope i could explain the issue or let me know i can try better. Thanks in advance
You need to put your static files under the wwwroot folder to make them accessible on the production server.
To include those files for publishing, a simplest option would be to add them to wwwroot before a publishing starts, otherwise they will be ignored.
Another option would be to tell MSBuild to include the files explicitly.
You can find an example of how to customize the project file at <Target Name="NgBuildAndAddToPublishOutput" AfterTargets="ComputeFilesToPublish">.
You could build for production with Angular CLI with --output-hashing=none like so:
ng build --prod --output-hashing=none
And then include the generated js-files into your project-file (csproj). Then use a Script-bundle in BundleConfig.cs with BundleTable.EnableOptimizations = true; to generate the hashes for you by ASP.NET instead of Angular-cli.

How to change script or style files location from nuget?

I have a MVC project and I am using jquery, bootstrap and some other files from nuget. In mvc by default all of scripts files is in Scripts and all of css files is in Content as you know. I moved all scripts and css files to Content/css , Content/js , after that i got a problem because the files are going to the default location (js => Scripts, css=> Content) when i update my nuget packages.
So how can i solve this problem ? Is it possible ?
In NuGet it is not possible to control where content files get installed to. The author of the NuGet package decides entirely what path to use for content files.
Instead of using NuGet for content files, I recommend using Bower, which is based on npm (the Node Package Manager).
With Bower you can control where files get installed to. Check out this SO post on the subject (especially the second answer): How to change bower's default components folder?
More info on Bower:
Getting started with Bower: http://blog.teamtreehouse.com/getting-started-bower
Bower support in Visual Studio: http://www.hanselman.com/blog/IntroducingGulpGruntBowerAndNpmSupportForVisualStudio.aspx

Publishing GulpJs minified/concatenated javascript via MSDeploy and Teamcity

Apologies if this question has been asked before. I have found variants on this theme but nothing that seems to fit our particular configuration.
We have developed a custom GulpJS task which parses a .json file located inside our folder assets/javascript. This json file contains an array of relative paths to javascript files (both our own and library) in a specific order for minification. They are then outputted to the folder assets/javascript/build and concatenated. The javascript source files are in the project but the minified and concatenated versions of the scripts, in fact the entire build folder itself, are not included in the Visual Studio project.
Ideally, I would like to have a step in the MSDeploy configuration which would copy all the files in the javascript build folder to the destination. Otherwise I could potentially include another step in Teamcity to do so.
Has anyone successfully instituted a similar build configuration and could share some insight? I tried using the MSBuild copy task but that didn't seem to copy the files to the output location. One option that I am considering is including the minified scripts in the project file but this might potentially trip up other developers who don't have Gulp running in their development environments (hilarious as that might be)

TFS Build single folder not being copied

when building my app on a TFS server, a single folder (with 2 .xml files) aren't copied to the output folder, but all others are.
These files are: a normal xml file and it's tranform version,
This is on the corporate TFS build server and it works for all other files / transformations. So it must be one of my settings in this project / File.
I've checked the files, it's set the same as a .css file that is getting copied (so set to content)
anyone has an idea where I could have a look to find why this is happening?
or even better has a solution for me.
Found that WIX was removing this file

Resources