dotnet / dotnet/AspNetCore.Docs
Nothing on the Grunt tutorial page works as described.
- Dominant language
- C#
- Stars
- 13.1k
- Forks
- 24.6k
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 97
Description
### Description
In the section [Preparing the Application](grunt.loadNpmTasks('grunt-contrib-watch');) 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](https://learn.microsoft.com/en-us/aspnet/core/client-side/using-grunt?view=aspnetcore-6.0#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](https://github.com/gruntjs/grunt-contrib-clean) 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](https://learn.microsoft.com/en-us/aspnet/core/client-side/using-grunt?view=aspnetcore-6.0#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
Contributor guide
Assessment
This issue has not been assessed yet.