I have created a sample app https://github.com/ajithvallabai/TestMethod in Visual studio 2019 . I want to run prebuild and build scripts in package.json https://github.com/ajithvallabai/TestMethod/blob/master/TestMethod/package.json#L10-L11 when we build the solution . Is there any way to do it ?
(In this app there is no build-events option in Project>properties
This method is only working for "buid" command https://learn.microsoft.com/en-us/visualstudio/javascript/compile-typescript-code-npm?view=vs-2022 that too it needs additonal files like .ts files .tcx files . but i want to run custom commands.
You can give answer for VS19/VS22 also
Related
Using Visual Studio 2019, I have downloaded all the dependencies needed to run NodeJS scripts and all works well. I can only run each .js script from VS (Ctrl+F5), but I want to know whether its possible to run a series of scripts like I would normally do via command prompt using npm start, but in real-time through VS? It's very important to me that I do not modify any script file in order to make this work, but rather let VS do the job instead of npm start, if It's possible at all.
I already have a project setup which I can successfully run via command prompt with npm start, but can I run and debug it with VS?
My main goal is to get any console output and even use breakpoints, aka. properly debug my code.
Actually, in VS IDE, there is a default node js project template that Microsoft provided.
You only have to install the workload Node.js development on the vs_installer so that you can use that template.
I think you should create such project template which follows the rule of VS IDE with node.js. And then migrate your old project's content into this new project.
Note: in this project, there is no such easy way to start several js files at the same time unless you nest nested js methods in the starting js file. And other types of projects do the same.
If you want to debug other js files, you only need to right-click on the file on the Solution Explorer. Every time switch like this, you can debug other js files.
You do not have to use npm start in this way and just click Debug to debug the project.
I am not sure about Visual studio, but you can debug on Visual Studio Code.
you can debug from run menu.
I following a step by step guide to configure Visual Studio 2019 in order develop a Node.js-React app.
The guide is here:
https://learn.microsoft.com/en-us/visualstudio/javascript/tutorial-nodejs-with-react-and-jsx?view=vs-2019
Briefly, the guide tells to configure an npm script (called "build") that should be fired when visual studio compiles, in order to generate app-bundle.js through typescript, using the app.tsx which contains a react component.
This must be done by adding the following code snipped to package.json
"scripts": {
"build": "webpack-cli app.tsx --config webpack-config.js"
}
however it doesn't work, because when i change something in app.tsx and run visual studio debbugger, the web page don't change at all.
If I run the following command using the nuget package console
npm run-script build
then it works fine!
So, is this a VS2019 bug, or is there some trick i miss?
Many Thanks for the help
I had similar problems like yours.
I solved this problem by this undocumented feature of visual studio 2017,2019:
BY manual editing,
You can add the following post-build event to package.json
"-vs-binding": { "AfterBuild": [ "build" ] }
by GUI,
in task runner explorer window,
select "build" task and let popup context menu open using right-mouse-button,
select bindings -> After build (make its preceding check box on)
this will add "-vs-binding" property to your package.json
Either one is okay. This works on vs 2017 and may works on vs 2019 either.
VS2017,2019 nodejs project build process seems
not to actually call my "build" script at all.
we should specify the "build" script as post-build event
for vs default nodejs build action.
It seems weired. I hope Microsoft solve this fault using patches.
task runner explorer capture image
I have been using CoffeeScript files within a project and have installed grunt into the project to compile them.
I am using Grunt Launcher to compile the files manually, but I wanted to be able to do so automatically when the project is built. To this end I put the following in the pre-build event command line under the project properties:
CD $(ProjectDir)
grunt build
This seems to work locally, but when I commit to the build server it comes back with this error:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1063,5): error MSB3073: grunt build" exited with code 9009
My research suggest that this is essentially a file not found; I presume for grunt. Some posts (here and here) suggest that added the full path is the answer, but what is the full path for grunt? Is it something like:
"path-to-project\node_modules\grunt\lib\grunt.js"
Grunt is installed both locally in the project and globally on my PC. I'm using Visual Studio 2012.
Is there anyway to get the build server to run grunt?
Thank you in advanced for any help.
Thank you to anyone who had a look at this question.
After a bit of experimenting I found putting this into the pre-build event command line works:
CD $(ProjectDir)
cmd.exe grunt build
Can anyone let me know how the build definition for a node.js application should look like? Also how to mention the mocha tests in the Automated tests?
First time when I tried to queue a build, I got an error saying:
Microsoft.NodejsTools.targets not found.
So I went and copied the NodejsTools folder with the .target and dll file in my build server. And I didn't see the error.
Now I get the below error:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\WebApplications\Microsoft.WebApplication.targets (132): Could not copy the file "obj\Debug\OstNodeJs.exe" because it was not found.
You need the node.js framework and the Visual Studio node.js Tools on you build server, too. You just copied the necessarily files and this may result in other problems.
For the executable copy problem you can try to add <Disable_CopyWebApplication>True</Disable_CopyWebApplication> in the project file. See here: Build on TFS wants to copy a executable from Node.js test project
I have an Azure cloud service project to which I am adding a cache worker role. While local build goes through fine, I get the following error on my server builds :
CloudServices38 : The entrypoint dll is not defined for worker role <cachename>
What is wrong? How do I fix this?
Make sure all the Azure DLLs are marked Copy Local = True in the properties window. Also, package your projects, then unzip them. Once you build the package, you will have a file YourProject.cspkg. Change the extension from .cspkg to .zip and extract the files. In these files you should see a file with the extension .cssx YourProject_.cssx. Change the extension from .cssx to .zip and extract again. You project that is deployed will be in the folder YourProject\sitesroot\0 - verufy all the files you are expecting (i.e. content and everything that is in the bin directory on your local build.
You need to run a Build and a Publish separately. I ran into the same problem on my project and this fixed it.
1) Visual Studio Build (or MSBuild) action with arguments /t:Build (clean here)
2) Visual Studio Build (or MSBuild) action with arguments /t:Publish (do not clean here)
Note: I had to run these actions separately (not /Build;Publish) otherwise I got an error about the cloud service entry point.
Pieced this together from this question and from here and here.