I'm working on an ASP.NET MVC 5 project that was initially using Nuget for static content like Bootstrap, jQuery etc. I have now switched to bower as it is the way to go and is also integrated with visual studio.
I noticed that when installing bower packages, they are not automatically included into the project. So I have left them out for now but is this a good idea? Should bower packages be included or not? It doesn't make any difference to access because in my BundleConfig.cs file I'm still able to link these files to aliases as before.
bower will download the entire package using Git.
Your package must be publically available at a Git endpoint (e.g., GitHub). Remember to push your Git tags!
This means that bower will actually download the entire repository/release for you to use in your ASP project. I've tested this with bootstrap and jQuery. These repositories can contain many many files so including them into the .csproj file will clutter your project file and may not be ideal.
This can be compared to using nuget packages where we are only referencing external packages in the packages.config file but we do not include the dll and other assemblies into the project. This leads me to think that bower_components should indeed not be included in the project; this makes no difference to usage as you can still reference the packages and use the files.
Related
My solution file contains a website project and some library projects. My website project is depending on these library projects and some other nuget packages. I have to build my .sln by MS Build. By executing nuget.exe all dependencies are loaded, but their references not updated to packages folder. When I google my problem I found the following solution.
https://www.codeproject.com/Articles/823752/ASP-NET-Website-Project-External-Assembly-Referenc.
But it did not solve my problem as I do not want to keep bin folder and I also do not want to keep the .refresh files of all the DLL. I need to load all external dependencies and referenced automatically, when I build .sln file.
ASP.NET website update assemblies references without modifying .refresh file
If I understand you correct, you can add a class library project to the solution, and add reference to the class library project to your website. Then, add the nuget in the class library, not the website project.
Then you could use nuget.exe update those nuget packages for the solution, like:
nuget.exe update "<YourWebsitePath>\WebSite1.sln"
In this way, When your build website, it pulls in all the class libraries' dependencies in turn.
If I am not understand you correct, please let me know for free and you can share a simple sample about your question, so that we could understand it more clearly.
Hope this helps.
I created a asp.net core MVC web App using the default project template. It adds few bower dependencies like: jquery, bootstrap, etc. These dependency are already downloaded at wwwroot\lib.
If I now right click on bower.json and click "Restore packages", I don't expect it to download anything new. But it gets a lot of new files, about 50 or so.
Is that expected?
Screenshots of before and after restore below.
Before
After
Yes, it is totally fine for Bower, don't worry, it worked so 3-4 years ago, when I started using it. The main idea that Bower does not download just dist files for Bootstrap or jQuery, but the whole repository from GitHub.
Moreover Bower does not provide any option to download only dist files. And it is intentional, you can read this discussion.
Some time I used bower-installer to keep dist files in separate folder, but eventually I just moved to npm/yarn + webpack anyway.
I'm using ASP.NET Core 1.0.1. My question is - should I push to Git all files that can be downloaded automatically by Bower?
like bootstrap/js/src or bootstrap/scss?
I mean, we usually don't push to Git whole packages referenced by NuGet, right? We are only pushing some config file with their "URIs", so that anyone can download the packages on their own, automatically when they build the project.
Is it different with Bower? Shouldn't we push to Git only changes made to bower.json file?
I've just started the project and GitHub shows me language statistics
like this:
And so far I've written like 2 simple functions, not the entire Bootstrap or jQuery :)
It is unnecessary to upload those files. As documentation says
Bower packages are installed using Bower install command, so everyone who clones you repository can install them himself.
I created a new asp.net project, and I am using the monodevelop as the ide.
On the left hand side in the explorer I can see two sections, one is called reference and the other called packages.
I assume that references are the library or dependency files like the jar equivalent of java. Then what are the packages section for?
Is it also another kind of dependency?
Can anybody help me understand the meaning of those two sections?
I assume you mean References and Packages. There is no Resources section/folder when I create an ASP.NET project in MonoDevelop.
The References folder will show the assemblies that are being referenced by your project. An assembly is equivalent to a jar file.
The Packages folder shows you the NuGet packages that are being used by your project. A NuGet package will typically provide assemblies and these will be shown inside the References folder but within a From Packages folder. A NuGet package may include other things, such as content files, which are added to the project, or custom MSBuild targets which modify the build behaviour.
I have a number of ASP.NET Web Form Websites (the one with no .csproj file), and I am trying to figure out how to best use NuGet packages with them. When using Visual Studio 2015, adding NuGet packages via the UI works correctly (there is a packages.config in the site root), and the build drops the binaries in the bin folder.
The problem is trying to build the project on TeamCity via MSBuild. For other projects, I can use NuGet.exe with the restore command (either against the csproj or the sln file), and the packages are correctly downloaded and included in the output. However, this doesn't work with the websites, and thus the compile fails due to missing files.
As a last resort, I could write a custom script/build step to manually copy the assemblies to the bin folder, but I'd like to avoid this. Am I missing something? Is there any way to use NuGet with websites outside of Visual Studio?
After some time, I have a workaround that gets me where I need to be, albeit not in the best way.
In newer versions of Visual Studio, when a binary dependency is added to a website via VS, it adds a (binaryfile).dll.refresh file to the bin folder alongside the binary file. The contents of the file is the relative path to the .dll via the packages folder for the solution. In addition, a packages.config file is added to the website.
The way to get it to build on a CI server is:
Ignore (.gitignore, .hgignore) the website's bin folder
Explicitly add the .refresh file(s) in the bin folder
Prior to the actual build, call NuGet restore, passing in the path to the website's packages.config and setting the PackagesDirectory (or SolutionDirectory) to the packages folder for the solution
Pre-Compile, MSBuild will open each refresh file, and copy the file from the location contained in the file.
It's not a great solution, because I now have to call NuGet restore multiple times (once for solution, once for each website), but it does work. I don't know how far back the .refresh file is supported, but it does work in 2015. I may make a change request in NuGet to allow for multiple solutions/packages.configs to be passed in via the command line.
Thanks,
Erick