I have two .net core applications running on Linux.
One of them is happy with .net core runtime while another one is demanding .net core SDK.
I can build both applications using dotnet publish with the following parameters:
dotnet publish Web/Web.csproj -o publish -c Release -r linux-x64 --self-contained false
Both projects target 3.1 (checked .csproj):
<TargetFramework>netcoreapp3.1</TargetFramework>
I am deploying them to the same VM server which has .net 3.1 runtime installed:
.NET Core SDKs installed:
No SDKs were found.
.NET Core runtimes installed:
Microsoft.AspNetCore.App 3.1.10 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.10 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
However, on start of one of those projects as systemctl service I am getting an error:
It was not possible to find any installed .NET Core SDKs
Did you mean to run .NET Core SDK commands? Install a .NET Core SDK from:
https://aka.ms/dotnet-download
While I can successfully start the application manually using dotnet Web.dll
Does my build artifact requires SDK?
Any ideas how can I troubleshoot this behavior?
1- No, it shouln't require SDK
2- Hard to help you with the incomplete question
Have you tried to run the service with SDK installed? To check if that is the actual problem or just a misleading error.
Are you using Systemd integration package by Microsoft?
dotnet add package Microsoft.Extensions.Hosting.Systemd
Related
Basically, I have a .netcore 3.1 proj (an exe) that runs flawlessly locally, both with and without a reference to another class library proj (.net framework 4.7.2). However, when I try to get the .netcore3.1 proj to build in Azure it only works when there is no reference to the class library. If there is a reference to the .net framework 4.7.2 class library, the build fails.
Below is the error within the publish portion of the pipeline. This is what comes up when the related code and reference to the class library are being used.
##[debug]Exit code 1 received from tool 'C:\hostedtoolcache\windows\dotnet\dotnet.exe'
##[debug]STDIO streams have closed for tool 'C:\hostedtoolcache\windows\dotnet\dotnet.exe'
##[error]Error: The process 'C:\hostedtoolcache\windows\dotnet\dotnet.exe' failed with exit code 1
##[debug]Processed: ##vso[task.issue type=error;]Error: The process 'C:\hostedtoolcache\windows\dotnet\dotnet.exe' failed with exit code 1
##[warning].NET 5 has some compatibility issues with older Nuget versions(<=5.7), so if you are using an older Nuget version(and not dotnet cli) to restore, then the dotnet cli commands (e.g. dotnet build) which rely on such restored packages might fail. To mitigate such error, you can either: (1) - Use dotnet cli to restore, (2) - Use Nuget version 5.8 to restore, (3) - Use global.json using an older sdk version(<=3) to build
##[debug]Processed: ##vso[task.issue type=warning;].NET 5 has some compatibility issues with older Nuget versions(<=5.7), so if you are using an older Nuget version(and not dotnet cli) to restore, then the dotnet cli commands (e.g. dotnet build) which rely on such restored packages might fail. To mitigate such error, you can either: (1) - Use dotnet cli to restore, (2) - Use Nuget version 5.8 to restore, (3) - Use global.json using an older sdk version(<=3) to build
Info: Azure Pipelines hosted agents have been updated and now contain .Net 5.x SDK/Runtime along with the older .Net Core version which are currently lts. Unless you have locked down a SDK version for your project(s), 5.x SDK might be picked up which might have breaking behavior as compared to previous versions. You can learn more about the breaking changes here: https://learn.microsoft.com/en-us/dotnet/core/tools/ and https://learn.microsoft.com/en-us/dotnet/core/compatibility/ . To learn about more such changes and troubleshoot, refer here: https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops#troubleshooting
##[debug]task result: Failed
##[error]Dotnet command failed with non-zero exit code on the following projects : D:\a\1\s\gwsCheckmarx\gwsCheckmarx.csproj
##[debug]Processed: ##vso[task.issue type=error;]Dotnet command failed with non-zero exit code on the following projects : D:\a\1\s\gwsCheckmarx\gwsCheckmarx.csproj
##[debug]Processed: ##vso[task.complete result=Failed;]Dotnet command failed with non-zero exit code on the following projects : D:\a\1\s\gwsCheckmarx\gwsCheckmarx.csproj
Finishing: dotnet publish dotnetcore
I find it weird how locally it runs fine, but on Azure only works without the project reference. Any ideas?
To avoid compatibility issues you should use for .NET Core 3.1 -> .NET Standard 2.1, because .NET Framework also implements .NET Standard, it is possible in some cases to include .NET Framework libraries in .NET Core projects but it is not a good practice.
If your app runs locally, the error can be because the dotnet sdk version that you are using locally is different that the one in the azure agent (from the error it is .NET 5). You can check by running this command in you local: $ dotnet --version
To set an specific version of the dotnet sdk for your project you can execute this command in the root folder of your solution file $ dotnet new globaljson, it will generate a global.json file in which you can set the dotnet sdk version you have in your local.
Other option is set the dotnet version in the agent with Use .NET Core YAML task, and after that run the build.
- task: UseDotNet#2
inputs:
packageType: 'sdk'
version: '3.1.401'
If you want to know the included software in the Azure pipeline VMs take a look at this link: https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/hosted?view=azure-devops&tabs=yaml#software
I'm running a test .Net Core Console app to try using ServiceBus messages. However after using Nuget to install Microsoft.Azure.ServiceBus v3.1.1 I get the following error
Package Microsoft.Azure.ServiceBus 3.1.1 is not compatible with netcoreapp1.1 (.NETCoreApp,Version=v1.1). Package Microsoft.Azure.ServiceBus 3.1.1 supports: netstandard2.0 (.NETStandard,Version=v2.0)
I've tried installing up to v3.3.0 and get the same, I'm using the latest .Net framework and have updated my VS2017 so I don't know what the problem can be. Has anyone else had this issue?
I don't know what the problem can be
No matter the version of package Microsoft.Azure.ServiceBus is v3.1.1 or v3.3.0, both of their Dependencies is .NETStandard 2.0 while your app is .NetStandard 1.0. So, as Peter said, the version of .net core you have is too old.
You could go to download the latest .Net Core SDK and then reinstall the package you want.
Or you could download the Microsoft.Azure.ServiceBus v1.0.0. However, because the version is too old, some feature may not have. So, I suggest that you could update your TargetFramework to .net core 2.0+.
Your console app needs to have a TargetFramework .net core 2.0+ (Check in .csproj file), download latest .NET Core SDK and create a new .Net core console app to install the package again.
I am following microsoft documentation to deploy .Net core with sql. when I go to my website the following is displayed:
An error occurred while starting the application. .NET Core X86
v4.1.1.0 | Microsoft.AspNetCore.Hosting version 1.1.2 |
Microsoft Windows 10.0.14393 | Need help?
When I run the app on local machine there are no errors and I am able to add toDo Items.
In my CsProj file:
<TargetFramework>netcoreapp1.1</TargetFramework>
I have seen other people with similar issue discuss a global.json file, but i do not see any and am not sure if I should create one and what exactly to put in it.
Possibly Related info:
When I push to azure in command line I get this error:
warning NU1701: Package 'Microsoft.Composition 1.0.27' was restored
using '.NETPortable,Version=v0.0,Profile=Profile259' instead of the
project target framework '.NETCoreApp,Version=v1.1'. This package may
not be fully compatible with your project. remote: Restore completed
in 269.7 ms for D:\home\site\repository\DotNetCoreSqlDb.csproj.
the deployment is successful though.
You could try to add the below to the <PropertyGroup> element in your DotNetCoreSqlDb.csproj
<PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8+wp8+wpa81;</PackageTargetFallback>
This is because the Microsoft.Composition 1.0.27 is an old nuget package which does not compatible with the your project target framework which is .NET Core 1.1.
The supported framework for the Microsoft.Composition 1.0.27 is as below:
Supported Platforms:
.NET Framework 4.5
Windows 8
Windows Phone 8.1
Windows Phone Silverlight 8
Portable Class Libraries
Reference: Package Microsoft.Composition 1.0.27 is not compatible with netcoreapp1.1
When publishing an ASP.NET Core application to a Linux server running nginx, is it necessary to install the .NET Core runtime on the server?
One of the options when publishing a .NET Core application is self contained deployments which include a version of the .NET Core runtime.
They are described (in the above link) as:
For a self-contained deployment, you deploy your app and any required third-party dependencies along with the version of .NET Core that you used to build the app. Creating an SCD doesn't include the native dependencies of .NET Core on various platforms, so these must be present before the app runs.
So your target machine will still need to have the libraries that .NET Core relies on, but it's entirely possible to publish you application and not have the .NET Core runtime installed on your target server.
Creating a SCD, you need to make a few changes to your csproj
<PropertyGroup>
<RuntimeIdentifiers>win10-x64;osx.10.11-x64</RuntimeIdentifiers>
</PropertyGroup>
The above would inform MSBuild that you want to target 64 bit Windows 10 and OSX 11.10.
Then you can create a published version of your app for one of those run platforms by running the following commands:
dotnet publish -c Release -r win10-x64
dotnet publish -c Release -r osx.10.11-x64
(the first line creates a SCD for Windows 10 64 bit, and the second does the same for OSX 10.11 64 bit.
Source: Self-contained deployment without third-party dependencies
I have my Azure Web App configured to deploy from a local git repository - I just push my changes to the Web App git repo and it builds and deploys the site.
I just updated to my ASP .NET Core site to: "version": "1.0.0-preview2-003133", previously it was 003131 which worked no problems.
I now get the response when doing the git push:
remote: GETSDKTOOLINGINFO : error : The project is configured to use .NET Core SDK version 1.0.0-preview2-003133 which is not installed or cannot be found under the path D:\Program Files (x86)\dotnet. These components are required to build and run this project. Download the version of .NET Core SDK specified in global.json or update the SDK version in global.json to the version that is installed.
I would prefer to update the .NET Core version on my Web App than downgrade, but how?
In case you are wonder how I have 3133 already: https://github.com/aspnet/Tooling/issues/801
You basically can not update the dotnet version on Azure. Currently the version of dotnet that is running is 003131. So you still have to use the previous version.
How are you building your release package?
I had this yesterday using a VSTS build process, when using the 'Visual Studio' build task it will fail with this error currently - changing your process to use the "CMD line" build task and "dotnet publish" allows the build to complete successfully.