dotnet test command started failing with MSBuild 17.4 - .net-core

We have been using ubuntu-latest agent in Azuredevops to build .netcore 3.1 projects from last one year. Things had been going very smooth until a week ago and all of the sudden, dotnet test command started failing with below error message
MSBUILD : error MSB1003: Specify a project or solution file. The current working directory does not contain a project or solution file.
When we dug deeper, we found that it started happening with MSBuild version 17.4. We then tried to use older version of ubuntu agent (which is using MSBuild 17.3) and then everything went well
I would like to understand the difference between MSBuild 17.3 and 17.4 and possible solution to fix this issue. Could anyone please help me on this?

I suppose that your issue is caused by the agent upgrades to support .NET 6 (.NET core 3.1 will be out of support in December). You could try to upgrade your project to .net 6 or higher.
Or you could test to add the property of <RuntimeFrameworkVersion>7.0.0<RuntimeFrameworkVersion>.

Related

VSCode Omnisharp server A .NET 6 SDK for x86_64 was not found

Omnisharp does not seem to recognize my installed .NET sdk (version 6.0.408).
I have tried manually adding this path via settings to Omnisharp: SDK path i.e.:
C:\Program Files\dotnet\sdk\6.0.403
I have also tried reinstalling the SDK and even VSCode.
This does not seem to solve the issue however, and I am unable to run my asp.net application on VSCode. Running dotnet run from the terminal is fine.
TLDR: Both .NET SDK versions and Visual Studion versions needed to be x64.
Here was the exact error I was seeing in the Output Window:
[ERROR] A .NET 6 SDK for x86_64 was not found. Please install the
latest x86_64 SDK from
https://dotnet.microsoft.com/en-us/download/dotnet/6.0.
[ERROR] Error: OmniSharp server load timed out. Use the
'omnisharp.projectLoadTimeout' setting to override the default delay
(one minute).
When I realized there was a mismatch between my .NET SDKs and Visual Studio Code in terms of being x86 and x64, I did the following:
Deleted the bin/obj folders and .vscode folders in my VS Code project.
Uninstalled my .NET SDKs via Windows (Setings > Apps).
Uninstalled Visual Studio Code via Windows (Setings > Apps).
Installed .NET 7.0 x64 and .NET 6.0 x64.
Opened PowerShell and ran dotnet --info to make sure my .NET runtime and SDK were appearing correctly.
Installed Visual Studio Code x64.
Used PowerShell and cd'd to my project folder. Did a dotnet restore. Then launched Visual Studio Code using code . command.
I could then use the most current version of the VS Code extension (v1.25.2).
Uninstalling and then installing the VSCode extension C# for Visual Studio Code solved the issue for me.
I had the same problem and just solved it. Copy and pasting this from a Youtube comment I just finished writing, so it might sound funny out of context, but the good bits are in there. Hope it helps.
Installed dotnet 7.0, but then it said dotnet 6 was missing...
So I deleted the script asset, exited Unity, went back to their website and installed Net 6.0.403
Error still happened.
I'll note this seemed to push a script compiling error out to Unity in the inspector window, as well.
Deleted the script asset again, exited Unity again, then uninstalled both dotnet 7 and dotnet 6.
Then I reinstalled dotnet 6.
Into unity, made a new script, opened it, and this time no error message about missing net 6.
I just started yesterday. Literally. So if my solution is trash, I'll laugh with you lol. Best of luck.

Downloading Correct Dotnet Architecture

I have a Mac running M1 Big Sur. When I got on my project 6 months ago I downloaded Dotnet 5 and everything was fine. Last night I downloaded VS 2022 (use VS Code for work) to learn via a Udemy video and it upgraded me to dotnet 6.0.4.
Today when I went to run my dotnet locally on my Run and Debug, I got this error
I've been trying for hours to find a compatible run time for the project but nothing I found is working, closest I got was this article here:
https://github.com/dotnet/runtime/issues/59168 which has a 14 step process further down.
I got dotnet 5 back on my machine, but now I get this error:
What do I need to do to get my architecture right to launch the project? To show my work, these are all the articles I have visited today, I promise I'm not being lazy, I just learned to code via a bootcamp 9 months ago and I am just now learning about these packages and how to use them, a lot of this is just going over my head. Any help would be appreciated.
My work:
https://github.com/dotnet/runtime/issues/52411
https://www.reddit.com/r/dotnet/comments/qwus6a/net_5_sdk_not_installing_properly_on_m1_mac/
https://learn.microsoft.com/en-us/dotnet/core/install/macos?tabs=netcore2x#dependencies
https://github.com/dotnet/sdk/issues/22380
The solution I found for resolving this was to manually remove dotnet from the usr/local/share folder. Then re-install dotnet 5.0 without dotnet 6.

Azure Function fails to build when TFM is upgraded from netcoreapp3.0 to netcoreapp3.1

We were trying to bump our dotnet version from a mix of .net 2.2 & .net core 3.0 to .net core 3.1 and we followed Jeff Holan's Dev post to upgrade which is surmarised as below
To change a project between ~2 and ~3 locally, update the .csproj file of the project and change:
AzureFunctionsVersion from v2 to v3
Microsoft.NET.Sdk.Functions package version to at least 3.0.1
Optionally, you can change to target netcoreapp3.1 if you want to target the latest .NET Core version
But while debugging Azure function project locally in VS Code, it still failed with an error message suggesting that there were still config remnants pointing to 3.0. Anyone encountered this issue?
[
[
On doing a full project search, we found that VS Code itself stored [i.e. in its .vscode directory], namely in two files: settings.json and tasks.json. Some config key value pairs still pointed to .net core 3.0 [perhaps these were added during when we were debugging the project when these were the current framework]. So for the migration from 2.2/3.0 to 3.1 we need to to ensure the references to the older frameworks are removed
We have to explicitly make the changes in tasks.json from netcoreapp3.0 to netcoreapp3.1
Ensure the deploy path in settings.json points to .net core 3.1
PS: In settings.json, project runtime is bumped upto 3 if you have followed Jeff Hollans dev article, otherwise it will mostly point to ~2

'{{FSharpCoreShippedPackageVersion}}' is not a valid version string

I just upgraded to Visual Studio 2019 version 16.5.0 Preview 2.0. It seems to have broken building and running .NET Core projects in F# with the dotnet command line tool.
Previously dotnet build and dotnet run worked fine. Now either one produces this error message (wrapped for readability):
C:\Program Files\dotnet\sdk\3.1.200-preview-014883\NuGet.targets(124,5):
error : '{{FSharpCoreShippedPackageVersion}}' is not a valid version string.
My projects don't have the string FSharpCoreShippedPackageVersion anywhere in them that I can see (including in the .fsproj files). I also looked in the referenced NuGet.targets file and couldn't find FSharpCoreShippedPackageVersion in it either.
Using dotnet new console --language=F# also fails, telling me to restore NuGet packages, but attempting dotnet restore gives the same error message.
What can I do to fix this?
UPDATE: This issue appears to be fixed in the current version of the preview:
3.1.200-preview-014977
If you update Visual Studio 2019 Preview, you shouldn't need this workaround anymore.
I found a workaround:
Run dotnet new globaljson in the project root folder
Edit the global.json to use .NET Core 3.1.101 instead of 3.1.200-preview-014883.
It appears that the combination of VS 2019 Version 16.5.0 Preview 2.0 and .NET Core 3.1.200-preview-014883 causes this problem.

System.Text.Encoding.CodePages missing in netcoreapp2.0 app

I just installed a clean install of the new .NET Core SDK on a CentOs 7 box. I had a different Linux VM I was running to test this and received the same error there.
I am building my application in VS 2017 on a Windows box and copying the project file over to the Linux box to test it. I am coming from netframework environment and trying to learn dotnetcore so I am sure this is probably just a newb issue. Here is what I am doing.
I run a dotnet restore, which works without error.
I run a dotnet build, which I receive a
Build succeeded.
0 Warning(s)
0 Error(s)
Then I run a dotnet run and receive the following error:
Error:
An assembly specified in the application dependencies manifest (apf-ws.deps.json) was not found:
package: 'System.Text.Encoding.CodePages', version: '4.3.0'
path: 'runtimes/unix/lib/netstandard1.3/System.Text.Encoding.CodePages.dll'
Nowhere in my code do I actually reference any type of Encoding explicitly. I have tried including System.Text.Encoding.CodePages in my project to see if that would add a reference and bring in the library to ignore the one it is looking for, but it doesn't help. Anyone have any ideas of what would be causing this?
I tried several things before wiping the directory out in Linux and copying the files over again. In doing so it seemed to fix the problem.

Resources