Local build of solution works in .NET 7 but not pipeline - c#

I have a large solution which I have updated from .NET Core 3.1 to .NET 7
This is all compiling on my local development machine
However, I get lots of failures when I build via DevOps pipeline
For example,
Has anyone had this issue? It really concerns me that this works on my local machine but not the pipeline and that key packages such as Auto Mapper are saying not supported on the pipeline, but compile fine locally
My pipeline is shown below

Your workaround for installing the latest nuget could be the only solution currently.
You could check this github ticket Nuget_Tool_Cache_issue#16800, a lot of developers are confused with this behavior.
Same issue was observed when I was trying to investigation further in this ticket. I suppose that it could be by design that the old Nuget 4.1 could not recognize the compatibility between the packages with the latest .Net 7.0
You could also raise a feature request ticket to raise more concern for future update on this behavior.

I will leave this question here as the issue is subtle
The windows-latest image doesnt have a recent version of nuget installed, its only 4.1
I fixed by adding the following before the nuget task
- task: NuGetToolInstaller#1
inputs:
versionSpec: '6.3.1'
checkLatest: true

Related

While running the project, I am getting an exception as System.InvalidOperationException: 'The host has not yet started'

I am facing this issue only for the particular repo as when I debug i found out that the version of the Azure core tool is older, I updated my Core Tools version from 4.0.4544 to 4.0.4915(x64)
Then after restart and deleting all the temp files when I run my application same error is thrown, and what I found the version is not updated , i check but couldn't find the older version core tool, all i can see is i have only one Azure core tool version which is 4.0.4915(x64)
So, is there any way to found out from where the application is getting the older version of Azure core tool in my local mechine.
I have deleted, and updated the version and also clear the temp file and restart my machine.
The running application is somehow showing the older version of core tool still now.
I checked everything launchSetting.json, jobHost.cs, local.setting.json, startup.cs
Every thing i correctly written.
As i checked with my buddies project only thing which is different is the Azure core tool version,
how to remove the default Azure core tool version and from where?
The terms on the Azure Functions Versions are:
Azure Functions Core Tools Version (V4)
Azure Functions Core Tools Versioned Commits Version (Such as 4.0.4544, 4.0.4653)
The Latest Version in Azure Functions Core Tools is v4 in the generic View.
Some patch updates will be done to the V4 version of AFCT regarding the existing feature breaking changes or adding the new features to it.
The earlier version you have is 4.0.4544 released on May 2022 with the following updates:
As you have updated to 4.0.4915 which is the latest patch update version to the v4 Azure Functions core tools, found in the official release GitHub Repos of AFCT.
When I run the Azure Function from the local IDE, I have got the below versions in the console:
From the above practical, we can say that the latest patch version of v4 Azure Functions Core Tools is 4.0.4915 but the AFCT Commit Version in the local is 4.0.4653 because the commit version of 4.0.4915 is not yet came to the Windows X64 OS Machine which is my current Machine Configuration.
Whereas the Core Tools Commit Patch Version 4.0.4653 is compatible with all the OS and bit-Configuration such Win X64, etc. So, this version 4.0.4653 is the current AFCT Commit Patch Version running the Azure Functions Host Runtime locally.
Note: You can check this path for the Commit Patch Versions of AFCT v4 in the C:\Users\<Your_User_Name>\AppData\Local\AzureFunctionsTools.

SDK Resolver Failure - Net 7 - Net 6

Just downloaded and installed SDK Net 7.0.100 and it broke existing applications and they won't load any more in VS 2022 or Rider.
Copied the follwing error:
error : SDK Resolver Failure: "The SDK resolver "Microsoft.DotNet.MSBuildSdkResolver"
failed while attempting to resolve the SDK "Microsoft.NET.Sdk". Exception: "Microsoft.NET.Sdk.WorkloadManifestReader.WorkloadManifestCompositionException: Workload definition 'wasm-tools' in manifest 'microsoft.net.workload.mono.toolchain.net7' [C:\Program Files\dotnet\sdk-manifests\7.0.100\microsoft.net.workload.mono.toolchain.net7\WorkloadManifest.json] conflicts with manifest 'microsoft.net.workload.mono.toolchain' [C:\Program Files\dotnet\sdk-manifests\7.0.100\microsoft.net.workload.mono.toolchain\WorkloadManifest.json]
at Microsoft.NET.Sdk.WorkloadManifestReader.WorkloadResolver.ComposeWorkloadManifests()
at Microsoft.NET.Sdk.WorkloadManifestReader.WorkloadResolver.Create(IWorkloadManifestProvider manifestProvider, String dotnetRootPath, String sdkVersion, String userProfileDir)
at Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver.CachingWorkloadResolver.Resolve(String sdkReferenceName, String dotnetRootPath, String sdkVersion, String userProfileDir)
at Microsoft.DotNet.MSBuildSdkResolver.DotNetMSBuildSdkResolver.Resolve(SdkReference sdkReference, SdkResolverContext context, SdkResultFactory factory)
at Microsoft.Build.BackEnd.SdkResolution.SdkResolverService.TryResolveSdkUsingSpecifiedResolvers(IList`1 resolvers, Int32 submissionId, SdkReference
I experienced a similar problem.
I uninstalled the 7.0.100-preview.5.22307.18 sdk using add remove programs and then changed the TargetFramework in the project file to use 7.0 and then I was able to load the projects.
EDIT: This is officially documented in the release notes known issues.
I'm from the .NET SDK team. Sorry you're going through this. I would love to comment on the other answers, but I don't have the reputation to do so.
What Tim Farley suggested is an officially endorsed workaround; uninstalling any preview 7 SDKs with add/remove programs should resolve the problem.
As for why this happened and why uninstalling preview SDKs will fix the issue, there's a bit of an explanation I put here: https://github.com/dotnet/sdk/issues/28947#issuecomment-1307987337.
TLDR: Some workloads were renamed in the middle of .NET 7 preview development to support things like multitargeting, and when you download the new RTM old preview files interfere can with it.
Updating the TargetFramework is recommended but it's unrelated to this issue. Usually breaking changes for each .NET version and related new features are gated behind your TargetFramework (TFM), so things don't break until you update the TFM, not when you update the SDK. (Unfortunately, not true in this case.)
In response to whether this will happen again or not when upgrading to .NET 8, per Scott: with how workloads are currently structured this issue would happen again. We're discussing how to make changes to prevent this from happening again though as it's not ideal. We're also considering adding dotnet workload clean or something to repair this for you. Communicating with us on the SDK GH thread, or with me here, is a good way to send us feedback about this.
Repairing Visual Studio installation did not help me. Neither did uninstalling .net 7 faulty workload ('wasm-tools'), since any attempt to uninstall or repair it ended up in the same error message.
Being ran out of conventional options to address the issue, I just went ahead and physically deleted the conflicting folder: microsoft.net.workload.mono.toolchain, leaving second one microsoft.net.workload.mono.toolchain.net7 intact. It luckily solved problems on my machine. From now on I'll be more cautious on installing Ms RC packages
I had a similar problem, even on new .Net projects. I uninstalled the 7.0.100-preview.2.22153.17 SDK using add remove programs and I was able to create a new project again. I am now left with only one .Net 7.0 SDK (from Visual Studio) as shown below.
Uninstall Microsoft .Net SDK 7.0 preview
I had the same issue as above except on my M1 mac. I followed the following guide and manually removed all the directories for all the .net 7 runtimes and sdks. Then reinstalled .net7 and all seems to be well now. rider can open my projects and the dotnet cli no longer complains
Not sure if a similar scorched earth approach will work for the windows folks.
https://devkimchi.com/2021/11/24/removing-dotnet-sdks-from-macos-manually/
I had the same issue, except that no preview version of .NET 7 was currently installed on my system, but the preview artifacts were still in the C:\Program Files\dotnet\sdk-manifests\7.0.100 directory. My solution was to uninstall the stable version of .NET 7 (not the version from VS 2022), then install and uninstall 7.0.100-preview.7. Doing so resulted in the preview artifacts being removed and this error being resolved.
I had same problem, but i think the problem because M1 mac
Had the same problem. Deleted manually installed net 7 sdks in windows uninstaller.
I found out that I needed to rm -rf **/obj
(delete all folders named obj) in the solution root folder after upgrading from net 6 to net 7, in addition to dotnet clean

What point release(s) does my aspnet mvc app run against if it targets ".NET Core 3.1"?

I recently updated our .net core asp.net mvc app, in the project properties, the Target Framework is ".NET Core 3.1". In the .csproj file I see:
<TargetFramework>netcoreapp3.1</TargetFramework>
At the time I built it the specific version was 3.1.3 which was listed as LTS (long term support).
If I expand the Dependencies -> then Frameworks -> right click on Microsoft.AspNetCore.App -> properties I see:
Version 3.1.3
QA tested the app and were preparing to release it.
But in the weeks that have followed, I noticed Microsoft released 3.1.4 (now listed as LTS). I'm confused on the issue of which version of .NET Core my app can run against in deployment.
Can the app run in a customer/deployment environment that has 3.1.4 installed since I never specified 3.1.3 explicitly. Or can it only run against 3.1.3 because that was the latest on my machine when I built it?
Thanks for the help, I feel stupid for not knowing this.
You misunderstood the LTS concept, https://dotnet.microsoft.com/platform/support/policy/dotnet-core
The only key point is that "Customers choosing LTS will need the latest patch update installed to qualify for support". You can use whatever patch version (3.1.x) till you need to upgrade to the latest when receiving support services from Microsoft. You should try to upgrade often to the latest patch version though, as it ships security updates.
Different deployment approaches (framework dependent or self-contained) also have impact on how you upgrade for yourself or your customers, but that's rather lengthy to discuss. You'd better set up a few experiments in a lab environment to explore further.

Getting multiple errors while running NUnit Test script on Azure Pipeline

I am working with the NUnit test in visual studio. On visual studio 2019, it running fine with no errors. But when I am making an azure pipeline for the same I am getting the multiple errors in the VSTest step just after VSBuild step.
I am attaching the screenshot defining the errors.
Help me with suitable solution if any.
According to this comment on this GitHub issue:
The problem is that System.Runtime.Loader is not supported on .NET Framework, this is a package that will only work on .NETCore App and UAP. We used to rely on a NuGet feature that wouldn't let this package install when targeting .NET Framework so you would get errors about this at compile time, but they changed this feature and now permit you to install the package and compile, so you now hit the error at runtime which is less than ideal. We could consider building a new version of this package that better stated that it is not supported on .NET Framework so that the incompatibility is found at compile-time.
The only solution seems to be use a different target framework.

Failed to upgrade Bot Framework Sample to latest nuget package versions on Azure

I've created a sample bot on Azure, downloaded it and upgraded all nuget packages to their latest stable versions. (Except for one package System.IdentityModel.Tokens.Jwt which Microsoft.Bot.Builder required to be less than 5.0)
Also changed .net framework to 4.7 and the C# compiler to the latest minor version.
Due to alleged backward compatibility I assumed this to work. And it does locally.
Bot emulator works just fine.
However back on Azure it does not. In the settings .net framework 4.7 was selected.
The homepage does not crash and is displayed correctly. However messages are not delivered to the bot.
I assume there is a limitation on Bot Builder SDK versions that azure supports,
but i did not find any such statement.
The logs show "HTTP Error 500.0 - Internal Server Error" Could not find more specific information.
Did anyone run into similar problem?
And in general, what's the best practice of upgrading your production application's libraries?

Categories

Resources