Blazor WebAssembly .NET6 upgrade to .NET7 causes JS module error - blazor-webassembly

I have an existing Blazor project that has target framework set to .NET 6.0.
After installing Visual Studio 17.4.1 and setting the target framework to .NET 7.0, I get a runtime error:
Uncaught SyntaxError: Cannot use 'import.meta' outside a module (at dotnet..3611wiw0dy.js:8:27)
What should I set to make it work?

You may need to upgrade your nuget packages to version 7.0
Eg.:
Microsoft.AspNetCore.Components.WebAssembly
Microsoft.AspNetCore.Components.WebAssembly.DevServer
Microsoft.AspNetCore.Components.Authorization
Microsoft.Extensions

Related

Can I publish targeting linux-armv6 runtime in .NET Core 7?

According to this issue and this runtime list for .NET Core v7.0, linux-armv6 is supported. However, when I try to target it with dotnet publish -r linux-armv6 I get the following error:
C:\Program Files\dotnet\sdk\7.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(135,5): error NETSDK1084: There is no application host available for the specified RuntimeIdentifier 'linux-armv6'.
What am I doing wrong?
armv6 in dotnet is only community supported. You can build it by yourself. If you want, I've build it from 7.0.0 source and put it in docker image for building my project. (I use linux-armv6/self contained)
https://hub.docker.com/r/taphome/dotnet7armv6
From my experience, dotnet is working pretty well on armv6. Problem is if you have some Nugets with native libraries which probably doesn't have armv6 version of native dependencies. I switched my app.libraries from mono/netstandard20 to net7 on armv6.

Cannot load Microsoft.Bcl.AsyncInterfaces

I have a .NET web application that works fine at my desk but when I deploy it to the server I'm getting this error:
"Could not load file or assembly 'Microsoft.Bcl.AsyncInterfaces' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded."
My project targets the .NET 4.6.1 framework and both machines have 4.8 installed. I already had the latest Microsoft.Bcl.AsyncInterfaces NuGet package installed so I attempted to revert to version 1.1 instead of the latest 5.0 and that didn't fix it.
I'm not sure what else to check. The Microsoft.Bcl.AsyncInterfaces.dll is in the bin folder.

Building net5.0 solution on TeamCity agent results in "reference assemblies not found" error

I have recently upgraded our .Net Core 2.2 application to .Net 5.0. I'm now trying to upgrade our TeamCity build agent, so it can build this solution.
Installed the .Net 5.0 SDK on the build agent, and restarted the machine.
Installed the latest Community edition of Visual Studio on the build agent as well.
When I try to run a build on the agent using "dotnet msbuild", it shows this error message:
[Building CodeEngineQueryBuilder4] C:\Program Files\dotnet\sdk\5.0.202\Microsoft.Common.CurrentVersion.targets(1216,5): error MSB3971: The reference assemblies for ".NETFramework,Version=v5.0" were not found. You might be using an older .NET SDK to target .NET 5.0 or higher. Update Visual Studio and/or your .NET SDK.
More info:
RDPed onto the build agent and run "dotnet --info" on the command line, which gave me ".Net SDK Version 5.0.203"
I did find directory "C:\Program Files\dotnet\sdk\5.0.203" on the build agent, so it seems .Net 5.0 is installed.
The build agent runs Windows 8.1.
The TeamCity installation is on the latest version.
What am I missing here?
In the end, I found that I had to change the system environment variable MSBuildSdksPath
to make it point at the new .net5 Sdk directory.
In my case, I repointed it at:
C:\Program Files\dotnet\sdk\5.0.203\Sdks

.NET Core 3.1 application not building on Azure pipeline anymore (.NET 5)

Until recently our .Net Core 3.1 applications were building and publishing fine on Azure pipelines. But over the last couple of days the build pipelines have started to fail with the error:
##[error]C:\Program Files\dotnet\sdk\5.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(241,5):
Error NETSDK1005: Assets file 'D:\a\1\s\ProjectFolder\src\Project\obj\project.assets.json' doesn't have a target for 'netcoreapp3.1'.
Ensure that restore has run and that you have included 'netcoreapp3.1' in the TargetFrameworks for your project.
(ResolvePackageAssets target) ->
C:\Program Files\dotnet\sdk\5.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(241,5):
error NETSDK1005: Assets file 'D:\a\1\s\ProjectFolder\src\Project\obj\project.assets.json' doesn't have a target for 'netcoreapp3.1'.
Ensure that restore has run and that you have included 'netcoreapp3.1' in the TargetFrameworks for your project. [D:\a\1\s\ProjectFolder\src\Project\Project.csproj]
The build pipeline is setup as follows for the solution build step that is failing.
Any ideas how to resolve this with the least amount of change?
.NET Core 3.1 application not building on Azure pipeline anymore (.NET 5)
Please try to update the nuget.exe to the 5.8.0 by the task NuGet tool installer:
You could check this thread for some more details.
had the same problem with a local build agent
error NETSDK1005: Assets file 'project.assets.json' ....
Update NuGet.exe to the 5.8.0 version or above
and clearing NuGet cache:
dotnet nuget locals all --clear
Download Nuget
found here

Azure DevOps pipeline fails at Restore - Test project is not compatible with netcoreapp2.2 Project supports: netcoreapp3.0

I have a solution with 2 projects:
Client Library project made for .NET Standard 2.0
Test project for .NET Core 3.0
And I created Azure DevOps pipeline which builds and packs this library for DevOps private Nuget feed.
The pipeline contains the following steps:
Use NuGet >= 5.3.1 (added this hoping to solve the issue)
Use .Net Core sdk 3.0.100 (added this hoping to solve the issue)
Restore packages
Build
...
But the process fails at Restore packages step with:
error NU1201: Project [Test Project] is not compatible with netcoreapp2.2 (.NETCoreApp,Version=v2.2). Project [Test Project] supports: netcoreapp3.0 (.NETCoreApp,Version=v3.0)
So how can I set up CI/CD for .Net Core 3.0?
I DO NOT use YAML - I hate that thing.
I tried "Use Nuget" to force the pipeline to use the latest Nuget.
I also tried to for it using the latest .Net Core 3.1.x.
All this doesn't help.
What helped was the re-creation of the test project. Now the pipeline works!

Resources