简体   繁体   English

ASP.NET 网络表单构建事件

[英]ASP.NET webforms build event

So basically I am attempting to have a build step that will change directory into my ./Clientapp folder and run an npm script that bundles the react app.所以基本上我试图有一个构建步骤,将目录更改为我的./Clientapp文件夹并运行捆绑反应应用程序的 npm 脚本。

I tried something like this Build step with a batch file in the root directory.我在根目录中使用批处理文件尝试了类似此构建步骤的操作。 But no luck with the batch file.但是批处理文件没有运气。 Was getting CD is unrecognized .正在获取CD is unrecognized But I want this build step to work in CI/CD as well, so that is why I went with a.bat file but wondering if there is a way in web.config instead to do this.但我希望这个构建步骤也能在 CI/CD 中工作,所以这就是为什么我使用 .bat 文件但想知道 web.config 中是否有办法代替这样做。

I think the build step should also be Before Build (Pre) because the bundles need to be included in wwwroot I am guessing.我认为构建步骤也应该Before Build (Pre) ,因为我猜这些捆绑包需要包含在 wwwroot 中。

Anyone know a good way to do this?有人知道这样做的好方法吗?

Project is using .NET 4.6.2 and Web Forms and VB.NET项目使用 .NET 4.6.2 和 Web Forms 和 ZBD5C8A1AFE53C83BA44F60C9ZAF6

You can create a new target that runs before the build.您可以创建一个在构建之前运行的新目标。

Inside that target just use the Exec task to execute your npm command.在该目标中,只需使用 Exec 任务来执行您的 npm 命令。 You can set the WorkingDirectory for this command, so no need to do a 'CD'您可以为此命令设置工作目录,因此无需执行“CD”

https://docs.microsoft.com/en-us/visualstudio/msbuild/exec-task?view=vs-2019 https://docs.microsoft.com/en-us/visualstudio/msbuild/exec-task?view=vs-2019

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

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