ASP.NET vNext with typescript - npm

I have downloaded the Visual studio 2015 RC to test the new ASP.NET vNext. Now I'm trying to build a MVC project with typescript.
I found that in vNext uses the following dependencies (correct me if I'm wrong):
Nuget for backend dependencies
Bower for client-side dependencies
Npm for client-side build dependencies
But who have to fetch definitions for typescript(*.d.ts like jquery.d.ts...)?
From the things I wrote above, it would have to be done by Bower, which does not have any typescript definitions. Similarly, Nuget does not include any typescript definitions that can be added to the project.

TSD Manager is a npm package. However understand your explicit categorization of what tool is used for what dependency doesn't exist. VS 2015 provides some templates but they are just that. Don't like grunt, gulp or bower and want to use a different task runner and package manager well you can use them as well right out of the box (as long as it can be installed by npm). Some web developers just use npm for everything instead of using npm & bower.
To specifically answer your question you can install the TypeScript Manager by adding "tsd": "0.6.3" to your packages.json file and doing a package restore.

But who have to fetch definitions for typescript(*.d.ts like jquery.d.ts...)?
TSD for typescript definitions: https://github.com/DefinitelyTyped/tsd

Related

how can I install package to the wwwroot in mvc core 2

Recently I Installed the VS 2017 Which Contains Asp.net mvc core 2
but there is a very confusion problems there!
that is how can i Install a new package into the wwwroot so:
_ Im using bower but supporting is end of and can not find out bower.json in the project>> new item after config it using npm . I installed it using npm but still can not find( .bowerrc file under bower.json.) to set the directory:
So-called valid document
_with gulp and grunt : end of supporting gulp too and can not find gulpfile.js in the project>>new Item after configure it using npm
please heeeeeeeeeeeeeeeelp me
You can use Library Manager:
Library Manager (“LibMan” for short) is Visual Studio’s experimental
client-side library acquisition tool. It provides a lightweight,
simple mechanism that helps users find and fetch library files from an
external source (such as CDNJS) and place them in your project.

Installing Nuget packages using Yarn without using Bower or npm

So I am seeing a lot of questions regarding .NET Core 2.1 and installing NuGet packages, but nobody has really recently addressed it clearly or (from what I've seen regarding my own configuration) correctly.
I'm trying to figure out how to install packages like jQueryUI or some other third-party packages from GitHub without using Bower (which is being deprecated), Webpack (which is entirely too bloated), or npm (which is far too confusing and doesn't actually get the packages installed where I need them, which is wwwroot/lib).
I am using Yarn as a client-side deployment tool, but Yarn isn't installing jQueryUI correctly. .NET Core is very, VERY new, and I think a lot of answers on SOF are taking some steps for granted.
Can someone please provide a clear path forward on how to install, say, jQueryUI and Bootstrap into a new .NET Core MVC Web Application (not the empty one)?

Can I execute npm install upon the installation of a NuGet package?

I'm creating a NuGet package which contains TypeScript dependencies...node_modules stuff. I don't want to include the node_modules as part of the package, so I'd prefer to execute npm install after the package installation completes. I've installed the package on a test website, and if I manually execute npm install it works.
I can put it in the readme to execute npm install after the package is completed, but I'd prefer to execute it automatically when the install is complete. Is there any way to make that happen?
Historically, we could write an Install.ps1 PowerShell script to invoke certain actions when installing a NuGet package. However, as of NuGet version 3, this feature is no longer supported:
Powershell script support was modified to no longer execute install and uninstall scripts, but init scripts are still executed.
The Init.ps1 script described above allows us to execute actions when a someone installs our package. Although the blog post above suggests that we can still use Init.ps1 scripts in our packages, the lack of recent documentation for this feature and a comment from a NuGet developer seem to indicate that Init.ps1 is also deprecated and that the behavior may not be available in the future. This makes sense if we consider that NuGet also aims to support Mac and Linux for Mono/.NET Core projects, and these systems do not yet include ubiquitous support for PowerShell like Windows (but they may eventually).
For these reasons, I cannot recommend at this time that we automate the package's post-install steps using NuGet's built-in features. The script that runs npm install must also handle challenges on systems where the npm program is missing or not available in the PATH, and some users may not like the idea of the package installing and running arbritrary code. I think it's fair for the project in question to simply instruct the end user in the README to run npm install after installation. Projects with more complex post-installation steps can instruct end users to run a script that executes each step. If you still wish to try using Init.ps1, continue reading:
The current NuGet docs omit information about Init.ps1, but older documentation from 2007 contains this description:
Init.ps1 runs the first time a package is installed in a solution. If the same package is installed into additional projects in the solution, the script is not run during those installations. The script also runs every time the solution is opened. For example, if you install a package, close Visual Studio, and then start Visual Studio and open the solution, the Init.ps1script runs again.
...
These files should be located in the tools directory of your package.
So, we can create an Init.ps1 file in the tools/ directory for our package which might look like the following:
param($installPath, $toolsPath, $package, $project)
Set-Location Path\To\Project\With\Node\Dependencies
npm install
...and then generate the NuGet package. The param() statement for the NuGet convention-based scripts provides the following values:
$installPath is the path to your package install
$toolsPath is the path to the tools directory under the package
$package is your package
$project is the project you are installing the application to. Note: This will be null in Init.ps1. It doesn't have a reference to a particular project because it runs at the solution level.
Because this script runs whenever we load a solution, it could slow down Visual Studio. We can add a condition to the script that checks if the packages are installed before running npm. Note that this functionality is restricted to NuGet operations run from Visual Studio or the Package Manager Console and likely will not work using the standalone NuGet CLI program because of the coupling of these scripts to projects and solutions.
Discussion to reintroduce Install.ps1 to NuGet

Compile Sass Files in .NET Core

I am trying to add Sass files to my .NET Core application in Visual Studio 2017. However, I cannot find any way to compile .scss files once I've made them. I sifted through NPM and Bower, but neither offer support for Sass.
The Microsoft documentation for adding Sass (https://learn.microsoft.com/en-us/aspnet/core/client-side/less-sass-fa) is outdated, and assumes that the project has a package.json file. Any guidance on enabling Sass compiling for my project would be much appreciated.
The easiest way to add .scss to your ASP.NET Core apps is by going to the Nuget Package Manager and installing LigerShark.WebOptimizer.Core and LigerShark.WebOptimizer.Sass.
After that, you can just put
<link rel="stylesheet" href="~/css/site.scss" />
in the head of the _Layout.cshtml file and the LigerShark.WebOptimizer.Sass package will compile all of your sass files automatically.
Use this extension for Visual Studio https://marketplace.visualstudio.com/items?itemName=MadsKristensen.WebCompiler
This extension not only lets you manually compile SASS/SCSS files to CSS, but it also adds a compilerconfig.json which can recompile your CSS every single time you click save.
Additionally, this extension can compile on project build via a nuget package it can install into your project. Which also enables CI/CD support.
This is by far the easiest way to add SCSS/SASS compilation to an ASP.NET Core Project when working inside of Visual Studio.
Try the article How to use Sass in ASP.NET Core 2.0 MVC
If I understood correctly, you can create a blank project.json with node package manager. And you can also configure auto build event with grunt.
Or better yet, follow this tutorial and manually add the file project.json to the project:
https://learn.microsoft.com/en-us/aspnet/core/client-side/less-sass-fa
(retired doc page, now redirects to fontawesome)
Seems that you have missed this part (that file should be created manually):
If you want SCSS compilation and bundling in one simple tool, try NBundle. (Apologies for the shameless self-plug!)
You specify which files to monitor (wildcards allowed) and the tool can be used to generate compiled and bundled files in a one-shot or "watcher" mode where output files are generated when the source files are saved.
How to accomplish this might depend on your workflow. I'd like it to be part of the build process as seamlessly as possible. So my prefered solution is using a dotnet tool called excubo.webcompiler(no I'm not affiliated in any way with the author). If you install it as a project tool
dotnet tool install Excubo.WebCompiler
you can add a simple target to your project file.
<Target Name="CompileStaticAssets" AfterTargets="AfterBuild">
<Exec Command="dotnet webcompiler -r wwwroot" StandardOutputImportance="high" />
</Target>
That will use the default settings which will often be sufficient. If not you can tweak the process using a configuration file
You simply need to add a package.json think you getting confused with project.json which was the old project system for .net core projects prior to switching back to .csproj
You can use live SASS compiler for compiling SCSS to CSS when the build occurs.
You have to add few line in the .csproj file and prior to that install live sass compiler from npm.
Here is my blog post: How to Use SCSS with ASP.NET Core 5.X or 3.X

Building asp.net core in Teamcity failing with dependencies

I am new to the DevOPs field. I am trying to build a .netcore project using teamcity which is failing with dependencies errors. The dependency System.Diagnostics.Contracts >= 4.0.1 could not be resolved. The dependency System.Net.WebSockets >= 4.0.0 could not be resolved. The dependency System.Runtime.Serialization.Primitives >= 4.1.1 The dependency System.Text.Encodings.Web >= 4.0.0 could not be resolved. I talked to one of the colleagues and he suggested to install the nugget packages but the solution is building on my and the devs system but is failing by Teamcity. how can I install the dependencies on teamcity. In Asp.net the nugget package management is done automatically(some one told me) So how to do it in .netcore.
found out that the terminology is called package restore and in dotnet core it is done by running
dotnet restore
from the directory where the project.json is located or the directory can be passed an an argument as well. After the restore there is no need to run msbuild. build can be done using
dotnet build
The new problem that I am facing now is that after the build and publishing the output folder to Azure web app I am unable to run my dot net core project as to run the project I need to run the command
dotnet nameoftheproject.dll
but I dont know how to run this command using teamcity after publish.