dotnet / AspNetCore.Docs

Documentation for ASP.NET Core
https://docs.microsoft.com/aspnet/core
Creative Commons Attribution 4.0 International
12.65k stars 25.28k forks source link

Nothing on the Grunt tutorial page works as described. #33368

Open Neutrino-Sunset opened 3 months ago

Neutrino-Sunset commented 3 months ago

Description

In the section Preparing the Application creating an ASP Core project using the ASP Core (empty) template does not create a project containing src or wwwroot directories.

There is no Tools > Options > Text Editor > Typescript > Project section, it is Tools > Options > Text Editor > JavaScript/TypeScript > Project

Selecting Automatically compile TypeScript files which are not part of a project has no effect.

Firstly the files being added in this tutorial are part of a project, so they should be automatically compiled anyway, but they are not.

Secondly, enabling this option does not change the fact that the TypeScript files are still not automatically compiled when modified and saved.

The instructions to create a JavaScript file and then rename it to a .ts file serves no purpose whatsoever. It behaves exactly the same as if you had just created a TypeScript file in the first place.

In the section Configuring NPM saving packages.json does not automatically restore the dependencies, you have to do that manually.

Running the clean task it appears to be defaulting to verbose mode, so instead of the tidier output seen in the tutorial it instead outputs this mess

C:\Users\Martin\Workspaces\Areas\Web\Editor\VsBundleTest2\VsBundleTest2> cmd.exe /c grunt -b "C:\Users\Martin\Workspaces\Areas\Web\Editor\VsBundleTest2\VsBundleTest2" --gruntfile "C:/Users/Martin/Workspaces/Areas/Web/Editor/VsBundleTest2/VsBundleTest2/Gruntfile.js" clean --color --force --verbose Initializing Command-line options: Reading "Gruntfile.js" Gruntfile...Registering Gruntfile tasks. Initializing config...Registering "grunt-contrib-clean" local Npm module tasks. --base=C:\Users\Martin\Workspaces\Areas\Web\Editor\VsBundleTest2\VsBundleTest2, --gruntfile=C:\Users\Martin\Workspaces\Areas\Web\Editor\VsBundleTest2\VsBundleTest2\Gruntfile.js, --color, --force, --verbose OK OK OK Reading C:\Users\Martin\Workspaces\Areas\Web\Editor\VsBundleTest2\VsBundleTest2\node_modules\grunt-contrib-clean\package.json...Parsing C:\Users\Martin\Workspaces\Areas\Web\Editor\VsBundleTest2\VsBundleTest2\node_modules\grunt-contrib-clean\package.json...OK OK Loading "clean.js" tasks...+ Registering "grunt-contrib-jshint" local Npm module tasks. Reading C:\Users\Martin\Workspaces\Areas\Web\Editor\VsBundleTest2\VsBundleTest2\node_modules\grunt-contrib-jshint\package.json...Parsing C:\Users\Martin\Workspaces\Areas\Web\Editor\VsBundleTest2\VsBundleTest2\node_modules\grunt-contrib-jshint\package.json...clean OK OK OK Loading "jshint.js" tasks...+ jshint Registering "grunt-contrib-concat" local Npm module tasks. Reading C:\Users\Martin\Workspaces\Areas\Web\Editor\VsBundleTest2\VsBundleTest2\node_modules\grunt-contrib-concat\package.json...Parsing C:\Users\Martin\Workspaces\Areas\Web\Editor\VsBundleTest2\VsBundleTest2\node_modules\grunt-contrib-concat\package.json...OK OK OK Loading "concat.js" tasks...+ concat Registering "grunt-contrib-uglify" local Npm module tasks. Reading C:\Users\Martin\Workspaces\Areas\Web\Editor\VsBundleTest2\VsBundleTest2\node_modules\grunt-contrib-uglify\package.json...Parsing C:\Users\Martin\Workspaces\Areas\Web\Editor\VsBundleTest2\VsBundleTest2\node_modules\grunt-contrib-uglify\package.json...OK OK OK OK Loading "uglify.js" tasks...+ uglify Registering "grunt-contrib-watch" local Npm module tasks. Reading C:\Users\Martin\Workspaces\Areas\Web\Editor\VsBundleTest2\VsBundleTest2\node_modules\grunt-contrib-watch\package.json...Parsing C:\Users\Martin\Workspaces\Areas\Web\Editor\VsBundleTest2\VsBundleTest2\node_modules\grunt-contrib-watch\package.json...OK OK OK Loading "watch.js" tasks...+ watch Loading "Gruntfile.js" tasks...+ Running tasks: Running "clean" task Running "clean:0" (clean) task Verifying property Files: Options: all clean clean.0 exists in config...OK [no src] -> 0 force, no-write=false

0 paths cleaned. Running "clean:1" (clean) task Verifying property Files: Options: clean.1 exists in config...OK [no src] -> 1 force, no-write=false 0 paths cleaned. Done. Process terminated with code 0.

The clean task also runs with --force even though according to the docs the default is force=false.

Attempting to explicity disable verbose and force using the following config has no effect.

      clean: {
         build: ['wwwroot/lib/*', 'temp/'],
         options: {
            force: false,
            verbose: false
         }
      },

Nothing in the Watching for Changes section works, because it's waiting for changes to the .js files, which never happen because the TypeScript files aren't being automatically compiled.

To get the TypeScript file compilation working you need to go to the file properties and select Build Action=TypeScript. Once you've done that the instruction to set Automatically compile TypeScript files which are not part of a project is pointles, since the TypeScript files are part of the project.

Page URL

https://learn.microsoft.com/en-us/aspnet/core/client-side/using-grunt?view=aspnetcore-6.0

Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/client-side/using-grunt.md

Document ID

5ea39e72-fcfc-ddbe-2f4d-f4166dfbe5a8

Article author

@Rick-Anderson

Neutrino-Sunset commented 3 months ago

It seems there is a bug in the VS2022 task runner explorer. When the Verbose toolbar button is selected verbose mode is disabled and vice-versa.

image

Rick-Anderson commented 3 months ago

It seems there is a bug in the VS2022 task runner explorer. When the Verbose toolbar button is selected verbose mode is disabled and vice-versa.

For Visual Studio, use the Report a Problem

Rick-Anderson commented 3 months ago

@mkArtakMSFT This is so out of date can we delete this article and redirect to