所以我很快。 我有一个运行VueJS项目的ASP.NET框架。 所以我想在VueJS文件夹中运行“ npm install”和“ npm run build”,仅使用“ dotnet run”命令启动ASP.NET。 我已经配置了“ npm run build”正在将文件构建到ASP.NET项目的wwwroot / client-app中,但是我必须在运行dotnet命令之前每次都运行build命令。 我试图向csproj添加一些代码,但是没有用。这意味着他没有更新wwwroot中的文件。
这是我添加到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>
即使有人可能错了,但有人可以帮助我解决问题,我将不胜感激。 所以简短的版本:我希望如果我运行dotnet run,那么两个命令npm install和run build都将要执行而无需单独运行
Thx ApFrePs
答案 0 :(得分:0)
您能获得的最接近的数字( 我假设您正在使用Visual Studio代码 )是creating a task。
{
"label": "build webapp",
"command": "dotnet build ${workspaceFolder}/(project-name)/(project-name).csproj && npm install && npm build",
"type": "shell",
"problemMatcher": "$msCompile"
}
然后您可以attach the task to launch.json赞:
{
"name": "Development: .NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build webapp" // <- THIS IS THE NAME OF THE TASK
.
.
.
.
.
.
.
}