npm.cmd opens in notepad instead of being executed (ASP.NET Web API + Angular) - node.js

I have a problem very similar to this one, but instead of a command line application, I have a ASP.NET Web API project with an Angular project inside of it, created using a dotnet template 'angular' (dotnet new angular --name something. .NET 6.0.401).
When I run the application with dotnet run and open localhost:5097 I get a blank page with a message "Launching the SPA proxy...
This page will automatically redirect to https://localhost:44415 when the SPA proxy is ready." The console constantly prints info: Microsoft.AspNetCore.SpaProxy.SpaProxyMiddleware[0]
SPA proxy is not ready. Returning temporary landing page.
over and over again.
When I enter localhost:44415 I get an error in the console that says
fail: Microsoft.AspNetCore.SpaProxy.SpaProxyLaunchManager[0]
Couldn't start the SPA development server with command 'npm start'.
and a notepad window is opened with content
:: Created by npm, please don't edit manually.
#ECHO OFF
SETLOCAL
SET "NODE_EXE=%~dp0\node.exe"
IF NOT EXIST "%NODE_EXE%" (
SET "NODE_EXE=node"
)
SET "NPM_CLI_JS=%~dp0\node_modules\npm\bin\npm-cli.js"
FOR /F "delims=" %%F IN ('CALL "%NODE_EXE%" "%NPM_CLI_JS%" prefix -g') DO (
SET "NPM_PREFIX_NPM_CLI_JS=%%F\node_modules\npm\bin\npm-cli.js"
)
IF EXIST "%NPM_PREFIX_NPM_CLI_JS%" (
SET "NPM_CLI_JS=%NPM_PREFIX_NPM_CLI_JS%"
)
"%NODE_EXE%" "%NPM_CLI_JS%" %*
which is understandably the same as the npm.cmd's content in my node.js directory. The window name is also "npm.cmd".
As mentioned in the thread I attached previously, I removed a file association for .js in windows settings, but it hasn't changed anything. The last comment there says something about changing the contents of "lb-discover.cmd" file. I don't think an ASP.NET + Angular project has an analogical file to it.
I suspect it might have something to do with file association in windows, but I can't change it for .cmd files.
Thanks in advance.

As suggested by #Yitz - this thing worked

Open your .csproj file for editing, find the following property:
<SpaProxyLaunchCommand>npm start</SpaProxyLaunchCommand>
and change it as follows:
<SpaProxyLaunchCommand>cmd.exe /c npm start</SpaProxyLaunchCommand>
This should work around possible issues with file association for .cmd

Related

How to sign in windows installer using electron builder

I am configuring package.json for windows. The packager is working fine. But, I also want to sign my windows installer file and unable to do.
I have gone through this tutorial WindowsConfiguration and got this line:
sign String | (configuration: CustomWindowsSignTaskConfiguration) =>
Promise - The custom function (or path to file or module id) to sign
Windows executable.
The problem is, I am not getting how to create JS file for windows installer signing and what parameters I have to use for its configurations. Thanks for your time.
With electron-builder, the only thing you need to sign your Windows application is to set this two Environment Variables CSC_LINK and CSC_KEY_PASSWORD as explained here : https://www.electron.build/code-signing.
-- alternative --
You can do the same by setting this in your package.json like this (but not recommended):
"build": {
...
"win": {
...
"certificateFile": "path to your cert",
"certificatePassword": "the password of your cert"
}
}
Hope this helps.
You can create your own signtool to sign what you need.
Firstly, you need signtool.exe from Microsoft: https://learn.microsoft.com/en-us/dotnet/framework/tools/signtool-exe
Then call child_process.exec to sign your file, for example:
exec(`call "${PATH_TO_SIGNTOOL_EXE}" sign /f "${KEY_SHA256}" /p ${PASS_KEY_SHA256} /fd sha256 /tr "http://sha256timestamp.ws.symantec.com/sha256/timestamp" /td sha256 /as /v "${FILE_TO_SIGN}"`)

build solution from command line

I'm trying to build a number of solutions from a cmd file using command lines to handle the whole build
this is the line that builds the solution:
for /f %%i in (%CFG%\bld.lst) do set OUT= %%i Release %REBUILD%& call :out & C:\"Program Files (x86)"\"Microsoft Visual Studio 12.0"\Common7\IDE\devenv.exe %%i %REBUILD% Release >>%LOG%
the solutions are in (%CFG%\bld.lst)
if I add error catching as in:
if errorlevel 1 set OUT= Failed to build %%i Release & goto :error_term at the end of the line the build crashes
if I don't then the eventviewer shows me this error:
The description for Event ID 0 from source VSTTExecution
cannot be found. Either the component that raises this event is not
installed on your local computer or the installation is corrupted. You
can install or repair the component on the local computer.
If the event originated on another computer, the display information
had to be saved with the event.
The following information was included with the event:
(devenv.exe, PID 2004, Thread 1) UIContextHelper.SetUIContext: The call to IVsAggregatableProject.GetCmdUIContextCookie failed. Error code: -2147467259
the message resource is present but the message is not found in the string/message table
if I build each of the solutions from VisualStudio the solution builds correctly
I should mention some of the projects where written in VS 2010 and some in VS 2013
it's turning my hair grey. HELP!
Danieli

Batch file make a website to homepage in all browsers

I've been looking for how to do this but failed.
I want a batch file to change the homepage for all my browsers (IE, Firefox and Chrome) at the same time may be?
I hope I can help, thanks!
Create a Batch file with
REG ADD "HKCU\SOFTWARE\MICROSOFT\INTERNET EXPLORER\MAIN" /V "START PAGE" /D "https://google.com/" /F
Double click it will make homepage in Internet explorer
In Internet Explorer:
you can do that like below:
REG ADD "HKCU\Software\Microsoft\Internet Explorer\Main" /V "Start Page" /D "http://www.google.com/" /F
In Firefox:
FF uses a JavaScript (prefs.js in your FireFox User Profile) and not a Registry entry.
What you will need to do is programmatically edit the prefs.js file in the user profile for Firefox found in the directory C:\Users\ [USERNAME]\AppData\Roaming\Mozilla\Firefox\Profiles\ [Subfolder]
You will need to add or edit the line that looks like: user_pref("browser.startup.homepage", "www.google.com"); as:
#Echo off
taskkill /im firefox.exe* /f
cd /D "%APPDATA%\Mozilla\Firefox\Profiles"
cd *.default
set ffile=%cd%
echo user_pref("browser.startup.homepage", "https://www.google.com");>>"%ffile%\prefs.js"
set ffile=
cd %windir%
Another option using JavaScript is:
You can change the Firefox homepage by setting the preference "browser.startup.homepage"
The easiest way to do this in an add-on via JavaScript is:
Components.utils.import("resource://gre/modules/Services.jsm");
Services.prefs.setCharPref("browser.startup.homepage", "http://www.google.com");
In Google chrome:
chrome settings are in %USERPROFILE%\Local Settings\Application Data\Google\Chrome\User Data.ChromotingConfig.json and are a little bit encrypted.
but you can do a workaround like by just pasting following javascript into the "Home Page" pref field (under your Chrome options) and it works as expected when clicking the "Home" button.
javascript:(function(){ window.location.href='http://www.google.com/';})();

How to remove multiple virtual directories?

I need to remove a big amount of virtual directories, some of them don't have associated physical directories.
Ideas?
As you need to remove a large amount, I'm guessing you'll want to use some form of script.
IIS 6.0, using IISvdir.vbs( article # MSDN):
At the command prompt, use the cd command to change to the directory where the Iisvdir.vbs script is installed. The default location for this file is systemroot/system32/iisvdir.vbs.
At the command prompt, type:
cscript iisvdir.vbs /delete "Sample Web Site" VirtualDirectoryName.
Substitute your Web site name and virtual directory name as appropriate. If there are spaces in the Web site name, use quotation marks around the Web site name, as shown in the preceding example.
IIS 7 using AppCmd.exe (article # TechNet):
To remove a virtual directory, use the following syntax:
appcmd delete vdir /vdir.name: string
The variable vdir.namestring is the virtual path of the virtual directory.
For example, to remove a virtual directory named photos from the root application of a site named contoso, type the following at the command prompt, and then press ENTER:
appcmd delete vdir /vdir.name: contoso / photos
To remove a virtual directory named photos from an application named marketing in a site named contoso, type the following at the command prompt, and then press ENTER:
appcmd delete vdir /vdir.name: contoso / marketing / photos
HTH
You could also write an msbuild script to do this and use the msbuild extension pack which is available here. I have used this successfully to do exactly what you are saying for 100s of vdirs in iis 6 AND in iis 7.5.
Its pretty simple and took me longer to write the .proj file than it did to figure out how to do it.
have fun :)
the resultant msbuild target would look like as follows
<Target Name="IIS7VirtualDirectories:Delete">
<MSBuild.ExtensionPack.Web.Iis7Application
TaskAction="Delete"
Website="%(Application.WebsiteName)"
Applications="#(Application)"
MachineName="$(MachineName)"
ContinueOnError="false"/>
<MSBuild.ExtensionPack.Web.Iis7Website
TaskAction="DeleteVirtualDirectory"
Name="%(VirtualDirectory.WebsiteName)"
VirtualDirectories="#(VirtualDirectory)"
ContinueOnError="false"
MachineName="$(MachineName)"/>
</Target>
Where Application and VirtualDirectory are defined in an external proj file :)

signtool fail with inno setup : 0x80070003 - "Store IsDiskFile() failed"

I'm getting a weird error whiles signing my software. I'm using inno setup 4.5.2.
Running Sign Tool command: signtool.exe sign /a /f cert.pfx /v /t "http://timestamp.verisign.com/scripts/timstamp.dll" /p pwd /d "Setup Label" "out\uninst.e32.tmp"
SignTool Error: An unexpected internal error has occurred.
Error information: "Error: Store IsDiskFile() failed." (-2147024893/0x80070003)
Error in W:\path\installer.iss: Sign Tool failed with exit code 0x1.
Compile aborted.
Command line seems pretty ok, it even work outside the inno setup compile. While setting the SignedUninstaller=no get me farther, it still make this error while trying to sign the output setup file.
Now i've looked pretty much everywhere for that error code (0x80070003) and/or the message "Store IsDiskFile() failed". I have also tried with multiple version of signtool.
I figured out the problem, the path to the certificate must be relative to the installer output path, not the current working folder. In this case, it would be "..\cert.pfx".
I had the same problem. My problem was I have used " in the signTool command, while I needed to use $q instead. Surprisingly it was successfully signed the executable but it failed to sign the result setup.exe file.
In my case I had the wrong Path for the certificate file. A message like "pfx not found" would much be better than just "IsDiskFile() failed."....
My problem was having the .pfx file on a network drive (G:). Moving it to a lokal drive (C:) solved the problem.

Resources