Build failing for Android after updating xamarin.forms - xamarin.forms

I have a Xamarin.Forms app. Yesterday, I updated Xamarin.Forms package to the latest version 4.8.0.1687. In Visual Studio 2019 I can build the app and run it. But build in Azure DevOps pipeline fails. For Android, the following error is reported:
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\My_MobileApp\My_MobileApp\obj\project.assets.json' doesn't have a target for 'netstandard2.0'. Ensure that restore has run and that you have included 'netstandard2.0' in the TargetFrameworks for your project. [D:\a\1\s\My_MobileApp\My_MobileApp\My_MobileApp.csproj]
Where My_MobileApp is the shared project.
I checked the project file, but the Target Framework there is set to .NET Standard 2.0. I checked the project.assets.json in the local obj folder, and it has
"originalTargetFrameworks": [
"netstandard2.0"
],
But no "TargetFrameworks".
What is wrong, and how this can be fixed?

Updating nuget to 5.8 worked for me

Related

Assets file project.assets.json doesn't have a target for 'net6.0-windows10.0.19041.0/win-x64'

I have a .NET 6 Windows Desktop app that I deploy with MSIX.
I can run and debug it on my own computer, but it fails to build with Azure Pipelines YAML.
I get the error:
C:\Program
Files\dotnet\sdk\6.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(267,5):
error NETSDK1047: Assets file 'D:\a\1\s\MyApp\obj\project.assets.json'
doesn't have a target for 'net6.0-windows10.0.19041.0/win-x64'. Ensure
that restore has run and that you have included
'net6.0-windows10.0.19041.0' in the TargetFrameworks for your project.
You may also need to include 'win-x64' in your project's
RuntimeIdentifiers.
App project file:
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
<Platforms>x64</Platforms>
Installer project file:
<TargetPlatformVersion>10.0.19041.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
The pipeline task is VSBuild with Visual Studio 2022 (v. 17)
Nuget tool is version 6.0 installed with NugetToolInstaller task.
Azure Windows agent uses vmImage: 'windows-2022'
The error says:
Ensure that you have included 'net6.0-windows10.0.19041.0' in the
TargetFrameworks for your project. You may also need to include
'win-x64' in your project's RuntimeIdentifiers.
I have added 'net6.0-windows10.0.19041.0' in the TargetFramework for both the app and the installer projects.
If I replace win10-x64 with win-x64 it can build, but I need to use win10-x64 because one of the packages requires it (Microsoft.PowerShell.SDK with System.Management.Automation).
NEW:
After adding /p:RestoreLockedMode=true in the VS Build task, I now get the error:
MyApp.Installer.wapproj : error NU1004: The project MyApp has no
compatible target framework. The packages lock file is inconsistent
with the project dependencies so restore can't be run in locked mode.
Disable the RestoreLockedMode MSBuild property or pass an explicit
--force-evaluate option to run restore to update the lock file.
NEW NEW: I upgraded to .NET 7 but get the same error.
How do I fix the error?

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

New project xamarin.form prism Error NETSDK1004 - Prism 2.2.1

when generating a new project xamarin.form prism I get this error when running. With the previous version 2.1.7 it worked for me OK.
It does not allow me to open the Nuget Package since it also gives an error.
Any recommendation?
I saw the 2 posts of this error but they do not apply to me.
Error NETSDK1004 Assets file 'C:\Empresas\Job_Facu\Job\Job.Prism\Job.Prism\obj\project.assets.json' not found. Run a NuGet package restore to generate this file. Job.Prism C:\Program Files\dotnet\sdk\3.1.202\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets 234
The error tells you what to do. Run a NuGet restore. Visual Studio should help you do this automatically. Note that if this occurred after updating dependencies sometimes Visual Studio gets confused and it's best to close Visual Studio and reopen it. This usually gets it to refresh itself so you get the updated package restore.
If that's not working for you, you can download the latest nuget.exe and from the command line navigate to the solution directory and execute the command {path to nuget.exe} restore.
When NuGet performs a restore it generates the project.assets.json file in the obj folder of each project it has restored. This in turn provides MSBuild with the reference information it needs to properly reference your dependencies like Prism and Xamarin.Forms.
I have recently ran into similar issue as well, seemingly out of the blue. I believe upgrading my build machine to the latest VS version (VS for Mac 8.10.4 (build 11))
NETSDK1004: */project.assets.json' not found. Run a NuGet package restore to generate this file.
To fix, I had to run Nuget Restore twice. Once for the shared project directory and once for the iOS project.
If I run the restore just for the Shared/(main.sln file) project directory I get the error.
If I run the restore for the iOS project the build passes but IPA file isn't created.
Need to run both.
Modules used for CI/CD build in Azure Devops Pipeline

Serilog.Extensions.Logging.File fails to be restored after configuring <RuntimeIdentifiers> in dotnet core 2.0 console app

I added Serilog.Extensions.Logging.File to my dotnet core 2.0 console app. It all went fine. When I add a runtime identifier to my .csproj in order to publish my project into an .exe (win7-x64), I get a Package restore failed error. Please help!

Resources