Files Not Appearing In Solution Explorer - visual-studio-2017

I am using Visual Studio 2017. I created an empty ASP.NET Core Web Application, and then installed the nuget package for Bootstrap through the Nuget Package Manager Console and the bootstrap .css and .js files aren't showing up in the solution explorer. Is this a bug or is there more to using nuget?

the bootstrap .css and .js files aren't showing up in the solution explorer. Is this a bug or is there more to using nuget?
That because the usage of NuGet for css/javascript libraries is discouraged. You should use the npm (Node Package Manager) to add the JavaScript libraries instead of using NuGet. The newer project file formats, PackageReferences, only supports files that are in a contentFiles directory inside the NuGet package.
To use the package Bootstrap to the .net core project, you need to select your ASP.NET Core Web Application and add a new file to the project root. While in the template manager (Add->New Item...), search for "npm Configuration file":
Then edit the file and add your dependency, i.e.
package.json (npm) or bower.json:
"dependencies": {
"Bootstrap": "4.1.3"
}
Note: Once you save, the file will be downloaded in a directory named "node_modules`. This alone won't be enough, as the required files need to be copied over to wwwroot folder, where they can be accessed when the application runs.
For the detailed info, see NPM, BOWER, NUGET, GULP – The Four Horsemen of ASP.NET CORE Apps and ASP.NET Core 2.0 and the End of Bower.
Hope this helps.

Content in the NuGet file that gets put into your project is only supported with packages.config, which is not supported in .NET Core. PackageReferences do not support getting content from the package.
I'm not 100% sure, but I think the ASP.NET team's recommendation is to use the preferred distribution method of the content you want to use. I haven't kept up with web development trends, but a few years ago web content like bootstrap were distributed with npm, so that's my recommendation for you. Creating a new Angular JS app with Microsoft's new web app template includes a npm package.json, so I think using npm is a safe bet.

Related

How to deploy files for Sitecore using TDS

I'm starting a new Sitecore 9 project using Helix and TDS. I've got my basic structure setup, using Hedgehog's fork of the Habitat site as a guide. I'm also referencing Hedgehog's docs.
My solution is just a start, so it's very simple right now, only a Foundation.Serialization module that contains the TDS projects for the basic layer folders and a Project.Website module that contains a TDS project and an MVC Website project (MVC)....it's got a basic Razor view and some random CSS/JS files.
The TDS Habitat readme, says to use Solution > Deploy Solution to deploy the projects. When I do this on my project it builds and the Sitecore items are deployed to Sitecore, but my Views and CSS/JS are not....presumably because I haven't configured anything to facilitate this.
Looking at the docs and the TDS Habitat solution, it's not clear to me how to configure TDS to know anything about how to deploy files. I'm finding info on the web that says that TDS will deploy files, transform configs, etc but with no examples of how to actually make that happen.
How do I set things up so Deploy Solution will also deploy files from all of the web projects in a solution to my local web root?
First, you will need to make sure the Sitecore Deploy Folder is set. From the documentation:
Sitecore Deploy Folder – Contains the path to the ROOT of the Sitecore
instance on the file system. This setting is used to install the TDS
Classic service when needed and to deploy the compiled code when the
TDS Classic project is built.
You also need to make sure that file deployment has not been disabled:
Disable File Deployment – Stops TDS Classic deploying files to the
directory specified in the Sitecore Deploy Folder.
If you are still not seeing the files being deployed, you will need to check if the process has access to the deploy folder.
You can also deploy files as a .update package and then use another automated tool to deploy the .update package to the target environment.
I figured out the issue. On the properties page for a TDS project there is a field where you indicate which projects should be built and deployed along with the sitecore items:
https://www.hhogdev.com/help/tds/propgeneral

npm "install" location in Visual Studio; .Net Core app

I'm just starting to play with my first .Net Core applications and am trying to use npm for client-side libraries. They get added to node_modules but aren't "installed" to wwwroot.
My question appears to have been asked before without answers:
How do I include libraries that installed via NPM to my MVC project on Visual Studio 2017
I've tried to install cropperjs. That works insofar that the files are downloaded and added to the node_modules folder:
projectfolder
node_modules
cropperjs
dist
src
package.json, changelog, readme, license etc. files
Now how would I get these files into my wwwroot directory to use them? The documentation is slightly confusing I'm afraid.
Thanks for enlightening me!
Sorry, found the answers after seeing the list of "related questions" to my own.
apparently, it is indeed required to copy the required files and folders over to the wwwroot location.
These two questions yielded answers and comments that solve my question:
How to access node_modules folder from wwwroot in asp.net vnext project
How to use npm with ASP.NET Core

Server can't find packages after upgrade

Private nuget server can't find packages after upgrade
I had to update the nuget server to get it to accept packages that were failing to upload (apparently the package format changed in dotnet core or something). Now all the previously uploaded packages aren't showing up in nuget. I can see all of them on the server just sitting there in their directories. But they can't be found. New packages are ending up in the server's package directory rather than their own directories.
From prior experience I don't think just copying the packages into the packages directory is going to work.
Trying to actually upgrade the NuGet.Server package from v2.8.6 to v3.0.2 appears to work but in the end the package is still at v2.8.6.
Don't try to upgrade nuget.server projects. That way lies madness.
Carry out the instructions like making a new one.
1) Create a new empty Web Project; target framework is NET Framework 4.6
2) Add NuGet.Server version 3.0.2
3) Fix duplicate <compilation> tag in web.config
4) Apply your API key to web.config and any other nuget configurations you have.
5) Remove old project from installation directory; leaving behind only the Packages directory and optionally any static files you uploaded to the installation directory itself (I keep a copy of nuget.exe and local project icons there).
6) Copy build output of new project to web installation directory.
It starts working. I don't know what's up with upgrading but it ends up with a smashed web.config and who knows what else.

Cannot add jquery using NuGet Package Manager in VS 2017

I tried to add jquery to an asp.net core project using NuGet Package Manager of Visual Studio Community 2017 (version 15.5.2), but there is no jquery js files added to my project. Here is the screenshot:
Tried with Bower Package Manager, then the files are downloaded to bower_components folder but not to wwwroot as many people said.
Same thing for jquery-ui, bootstrap, etc.
Anyone experienced the same problem. Is there any work-around?
BTW, this accepted solution doesn't work for me: Where are jQuery-UI scripts stored in MVC6 project?
For ASP.NET Core in Visual Studio 2017:
NuGet shouldn't be used for client-side libraries.
After that Bower was used for this purpose, but now it is deprecated.
Currently the supported tool for managing client-side libraries is LibMan. Here is very good explanation how to use it in VS2017.

Customize web deployment package in Visual Studio 2010

I have a WCF DataService build in VS 2010, targetting .Net 4.0. This all works fine. I've created a deployment package and have the application deployed to a web server using MSDeploy and a zip file. When I set up an automated build on a TFS Build Agent the contents of the deployment package changed. I no longer get the strong named assemblies in my deployment package. These excluded assemblies are projects within the solution and are built on the Build Server.
I don't see a lot of configuration options for the deployment package, but I would like to know why the build server creates a different package than my workstation, using the same settings.
I am using "Only files needed to run this application", I have ticked "Exclude generated debug symbols" and "Exclude files from App_Data folder". I _do_not_ include database packages. I do create a zip file (which is missing the strong named assemblies)
Thanks for any information you may have explaining why this occurs. Then maybe I can solve the problem.
Beezler
On the build server I've ungaced the assemblies I was concerned about and that got my deployment package to the state I want it. So it appears the deployment package does not include the GACed assemblies, which is a good thing. I would still like to know how to override this behavior on certain referenced assemblies.
Thanks,
If you want to include a DLL files for a GAC assembly do the following:
In your project, expand the "References" folder
right-click on the reference you want to include the DLL and click "properties" to bring up the properties pane
set "Copy Local" to "True"
That's it! When publishing your project, it will include the DLL in the bin folder for that reference!