I'm using Microsoft.AspNetCore.NodeServices 1.1.1 in my ASP.Net Core application. Everything has been working fine, but now I'm on a new computer and I get the following error:
System.InvalidOperationException:
Failed to start Node process. To resolve this:.
[1] Ensure that Node.js is installed and can be found in one of the PATH directories.
Current PATH enviroment variable is: ....
Make sure the Node executable is in one of those directories, or update your PATH.
[2] See the InnerException for further details of the cause.
I have removed the path variables from this question, but the directory where Node is installed is listed in there.
node -v in a terminal gives me v6.11.0 so it is added to the path.
Nothing in the code has changed since it last worked, only my computer. Does anyone know what could be wrong?
After debugging I found out that it was due to a missing folder.
This is how NodeServices was configured in Startup.cs:
services.AddNodeServices(options =>
{
options.ProjectPath = "Path\That\Doesnt\Exist";
});
Once I added that path, everything runs okay.
You can use this code snippet to get a client project
services.AddNodeServices(options =>{
options.ProjectPath = Path.Combine(Directory.GetCurrentDirectory(), "ClientApp"); });
For me the error was caused after upgrading my website from Net Core 2.2 to 3.0.
The upgrade altered my web.config file, in particular this part:
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath=".\MyWebsite.exe" arguments="" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
became this:
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" hostingModel="inprocess">
<environmentVariables>
<environmentVariable name="COMPLUS_ForceENC" value="1" />
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
</environmentVariables>
</aspNetCore>
I fixed the issue by setting processPath and arguments back their previous values, and completely removed the <environmentVariables> section.
Related
ASP.NET Core 3.1 project uses the following line in csproj to copy a customized web.config from the wwwroot folder into the output folder:
<ItemGroup>
<Content Update="wwwroot\Web.config" CopyToOutputDirectory="Always" CopyToPublishDirectory="Always" Link="%(Filename)%(Extension)" />
</ItemGroup>
The project is compiled using Azure DevOps classic (non-YAML) pipeline:
.NET Core task (Task version 2.0), command restore
.NET Core task (Task version 2.0), command build
.NET Core task (Task version 2.0), command publish with [x] Publish web projects, [x] Zip published projects and [x] Add project's folder name to publish path
Publish build artifacts task (Task version 1.0)
Builds up to July 2020 retained the customized web.config in the build artifact as expected, just with the following lines being injected to the customized web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<...>our custom settings defaultDocument, staticContent, rewrite and rewriteMaps</...>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2"
resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\Something.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
</system.webServer>
</configuration>
<!--ProjectGuid: SOME-GUID -->
But the builds made yesterday and today contains different web.config, missing the customized parts while adding a <location> tag:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\Something.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>
<!--ProjectGuid: SOME-GUID -->
Note: There were no builds between July and yesterday. The only change made in the project source was just a few unrelated minor text changes in Razor views. The pipeline definition is kept unchanged for at least a year.
July's build agent logged these versions:
Current agent version: '2.171.1'
Current image version: '20200630.0'
Downloading task: DotNetCoreCLI (2.171.3)
Downloading task: PublishBuildArtifacts (1.158.3)
November's build agent logged these versions:
Current agent version: '2.177.1'
Included Software: https://github.com/actions/virtual-environments/blob/win19/20201116.1/images/win/Windows2019-Readme.md
Current image version: '20201116.1'
Downloading task: DotNetCoreCLI (2.175.0)
Downloading task: PublishBuildArtifacts (1.158.3)
Why the web.config in the artifacts no longer contains the customized part? How to fix it?
I'm upgrading an existing ASP.NET Core 2.2 application to 3.0.
When I publish and host my APIs inside local IIS, I get the HTTP Error 502.5 - Process Failure page. The point is, I don't see the logs being written to the stdoutLogFile location.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\bin\MyApplication.dll" stdoutLogEnabled="true" stdoutLogFile=".\bin\Logs\" hostingModel="inprocess" />
</system.webServer>
</configuration>
I've changed the output folder from \bin\Debug\netcoreapp3.0\ to \bin\ via these configurations:
<PropertyGroup>
<OutputPath>.\bin</OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
</PropertyGroup>
I also have a folder called Logs in my \bin\ folder.
But when I call my API, I get this error in Error Viewer:
Warning: Could not create stdoutLogFile
C:\PathToMyProjectFile\bin\Debug\netcoreapp2.2_19212_2019102292022.log,
ErrorCode = -2147024893.
The point is, I'm not using 2.2 anymore. How should I solve this?
you have to modify the generated web.config by removing the "V2" in modules="AspNetCoreModuleV2", in order to have: modules="AspNetCoreModule".
Hope this helps
I'm new to this .NET Core stuff and this is the first time I've tried to deploy one of these.
The project is an API for an Angular front end I'm building and takes HTTP requests and returns JSON. When I run it in Visual Studio on my box it is all fine. I'm running VS2017 and have .NET Core 2.0.0 installed.
I publish to a folder on the web server and it all seems to work fine, but when I try to access the API I get a 404 not found error. The server is running .NET 2.0.6 (I tried to get 2.0.0 but couldn't find it in the Hosting Bundle Installer.
If I delete the web.config the HTML file will then show up, but obviously the API doesn't work. But as the HTML file shows up there is no issue with permissions and access. There's nothing in the Event Viewer. I've also tried turning on the logging in the web.config, but it doesn't log... probably not getting far enough to.
Web config looks like this.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\RawMaterialsSystem.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</configuration>
<!--ProjectGuid: f01b1621-2ced-4ad2-9ae6-004e03b0e043-->`
STEP 1: Change your web.config file to this
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!--
Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380
-->
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</configuration>
STEP 2:
In visual studio, right click the .net core app project and select "Publish"
Then publish it as a folder under bin\Release\netcoreapp2.0\publish
STEP 3:
In IIS --> Sites --> Right click on YourSite --> Under "Manage Website" select "Advanced Settings"
Make sure the "Physical Path" you are pointing to is the "publish" folder as the app directory, and not the "netcoreapp2.0" folder
I use ASP.NET Core 1.1.
When I publish my application the IHostingEnvironment always return the environment as "Production".
I made some attempts via the web.config as follows:
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false">
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
</environmentVariables>
</aspNetCore>
</system.webServer>
Unfortunately it doesn't has any effect.
I also get a warning about that the aspNetCore is invalid child of system.webServer...
I have seen at the project.json the scripts entry that runs dotnet publish-iis command but couldn't find any environment parameter.
I have tried to pass the publish command --iis-command (As described in this post) but it doesn't identify this parameter.
I will highly appreciate your thoughts about it...
I installed a sitecore instance with SIM, and checked the project for a MVC solution, what I don't get is why the #Html.Sitecore() is not working:
Error 2 'System.Web.WebPages.Html.HtmlHelper' does not contain a definition for 'Sitecore' and no extension method 'Sitecore' accepting a first argument of type 'System.Web.WebPages.Html.HtmlHelper' could be found (are you missing a using directive or an assembly reference?)
I have the /Views/Web.config with the following:
<namespaces>
<add namespace="Sitecore.Mvc" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
</namespaces>
Is there something different that needs to be done when running a solution inside the "Website" folder vs publishing to the Website folder?