简体   繁体   English

仅使用“ dotnet run”运行“ npm run build”

[英]run “npm run build” with only “dotnet run”

so I make it quick. 所以我很快。 I have an ASP.NET framework running with a VueJS-Project in it. 我有一个运行VueJS项目的ASP.NET框架。 So I want to run "npm install" and "npm run build" inside the VueJS-folder with only the "dotnet run" command for starting the ASP.NET. 所以我想在VueJS文件夹中运行“ npm install”和“ npm run build”,仅使用“ dotnet run”命令启动ASP.NET。 I already configured that "npm run build" is building the files into the wwwroot/client-app of the ASP.NET-project but I have to run the build command everytime before running the dotnet command. 我已经配置了“ npm run build”正在将文件构建到ASP.NET项目的wwwroot / client-app中,但是我必须在运行dotnet命令之前每次都运行build命令。 I tried to add some code to the csproj but it doesn't worked. 我试图向csproj添加一些代码,但是没有用。 That means he isn't updating the files in wwwroot. 这意味着他没有更新wwwroot中的文件。

This is what I added to my csproj-file: 这是我添加到csproj文件中的内容:

<Target Name="client-app" BeforeTargets="ComputeFilesToPublish">
    <Exec Command="npm install" WorkingDirectory="client-app"></Exec>
    <Exec Command="npm run build" WorkingDirectory="client-app"></Exec>
</Target>

I would appreciate it if someone could help me with the problem even though I may be quite wrong. 如果有人可以帮助我解决这个问题,即使我可能是错的,我也将不胜感激。 So the short version: I want that if I run dotnet run also the both commands npm install and run build are going to be executed without run them separately 所以简短的版本:我希望如果我运行dotnet run,那么两个命令npm install和run build也将要执行而不必分别运行它们

Thx ApFrePs Thx ApFrePs

The closest you can get ( i suppose you are using visual studio code ) is creating a task that does that. 您所能获得的最接近的结果( 我想您正在使用Visual Studio代码 )正在创建执行此任务的任务

{
  "label": "build webapp",
  "command": "dotnet build ${workspaceFolder}/(project-name)/(project-name).csproj && npm install && npm build",
  "type": "shell",
  "problemMatcher": "$msCompile"
}

Then you can attach the task to launch.json like: 然后,您可以将任务附加到launch.json,如下所示:

{
  "name": "Development: .NET Core Launch (web)",
  "type": "coreclr",
  "request": "launch",
  "preLaunchTask": "build webapp" // <- THIS IS THE NAME OF THE TASK
.
.
.
.
.
.
.
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM