29

With the latest VS preview (VS 17.3 Preview 3), with both Android and iOS, building my application works the first time I build it, but the second time it fails with

The "XamarinTelemetry" task failed unexpectedly.

Looking at the logs I see this:

1>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Xamarin\Xamarin.Sdk.targets(138,9): error MSB4018: The "XamarinTelemetry" task failed unexpectedly.
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Xamarin\Xamarin.Sdk.targets(138,9): error MSB4018: System.IO.FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Xamarin\Xamarin.Sdk.targets(138,9): error MSB4018: File name: 'Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Xamarin\Xamarin.Sdk.targets(138,9): error MSB4018:    at Microsoft.VisualStudio.Telemetry.TelemetrySessionSettings.GetFaultEventBucketFilterJson(List`1 bucketFilters)
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Xamarin\Xamarin.Sdk.targets(138,9): error MSB4018:    at Microsoft.VisualStudio.Telemetry.TelemetrySessionSettings.ToString()
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Xamarin\Xamarin.Sdk.targets(138,9): error MSB4018:    at Microsoft.VisualStudio.Telemetry.TelemetrySession.SerializeSettings()
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Xamarin\Xamarin.Sdk.targets(138,9): error MSB4018:    at Xamarin.Common.Tasks.Telemetry.GetSession(IBuildEngine4 buildEngine, String vsTelemetrySession) in D:\a\_work\1\s\src\MSBuild\Xamarin.Common.Tasks\Telemetry.cs:line 62
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Xamarin\Xamarin.Sdk.targets(138,9): error MSB4018:    at Xamarin.Common.Tasks.XamarinTelemetry.Execute() in D:\a\_work\1\s\src\MSBuild\Xamarin.Common.Tasks\XamarinTelemetry.cs:line 31
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Xamarin\Xamarin.Sdk.targets(138,9): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Xamarin\Xamarin.Sdk.targets(138,9): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Xamarin\Xamarin.Sdk.targets(138,9): error MSB4018: 
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Xamarin\Xamarin.Sdk.targets(138,9): error MSB4018: WRN: Assembly binding logging is turned OFF.
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Xamarin\Xamarin.Sdk.targets(138,9): error MSB4018: To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Xamarin\Xamarin.Sdk.targets(138,9): error MSB4018: Note: There is some performance penalty associated with assembly bind failure logging.
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Xamarin\Xamarin.Sdk.targets(138,9): error MSB4018: To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Xamarin\Xamarin.Sdk.targets(138,9): error MSB4018:

The only workaround I've found is to clean the entire solution and rebuild, which succeeds, but then fails again the next time I try to build.

Has anyone found a solution to this?

BlueRaja - Danny Pflughoeft
  • 84,206
  • 33
  • 197
  • 283

6 Answers6

31

First off, don't shoot the messenger here..

UPDATE: August 16, 2022

According to Visual Studio v17.3.1's Release Notes, this issue has been resolved. However, if not, there's still the following

As per the workaround thread on Visual Studio's dev community thread:

  1. Open, Xamarin.Sdk.targets in Admin Mode (I use, Notepad++)
    • C:\Program Files\Microsoft Visual Studio\2022\Preview\Msbuild\Xamarin\Xamarin.Sdk.targets
  2. Comment out the <XamarinTelemetry ... />
  3. Save file and rebuild the solution.

Though it does work in the interim, please forward your official feedback on the official VS Developer Community thread in the link below.

Damian
  • 1,209
  • 14
  • 24
  • 1
    this works well, but the telemetry comes back from the dead. Not sure what causes it to re-emerge but if it stops working check there again. – Jesse Liberty Jul 26 '22 at 11:41
  • I'm with you. So far, it's been playing well for me so far. But at least it's a quick bandaid until MS addresses the real issue. – Damian Jul 26 '22 at 14:37
  • 4
    what is XamarinTelemetry for? are they reporting things secretly? :D – Emil Aug 09 '22 at 19:56
  • 2
    FYI it fixes it for me on the just release VS2022 - Maui ready ;) – kenny Aug 10 '22 at 13:06
  • 1
    Removed the error for me as well in Visual Studio 2022 v. 17.3. But will commenting this out have any repercussion during archive deployment to the app stores? – chri3g91 Aug 10 '22 at 13:51
  • 6
    Just a warning that this error does still occur periodically in 17.3 and even still in 17.4 preview. I've been using 17.3 previews for a while, and it seems to be something in the last couple of weeks that it's really become a problem, I think the telemetry backend is the problem, not the target itself, but removing the target is probably the easiest "fix". – Captain Obvious Aug 11 '22 at 09:39
2

There are several config files in the VS installation which reference 13.0.0.0

<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />

I replaced these with

<bindingRedirect oldVersion="0.0.0.0-13.0.1.0" newVersion="13.0.1.0" />

and was able to build. It seems that the 13.0.0.0 is not publicly available as nuget package...

Michael O
  • 67
  • 5
  • 1
    Unfortunately, while this works and allows the project to build without cleaning, it leads to lots of warnings and other issues (like [this](https://stackoverflow.com/questions/18311108/test-method-is-inconclusive-test-wasnt-run-error)) – BlueRaja - Danny Pflughoeft Jul 24 '22 at 21:59
1

In Visual Studio 17.3.0, I right-clicked on the projects and selected "Clean".

Then I tried again to right-click the project and selected "Build" and it worked, the "The XamarinTelemetry task failed unexpectedly" error did not occur.

This is in a solution that contains a .NET Standard 2.0 library that references Xamarin Forms and the project in question is an ASP.NET Core 3.1 API referencing the library.

ehuna
  • 163
  • 6
0

I experienced this today and all I did was rebuild the solution, clicked the "save all", closed the application and opened it again but it did not work. I rebuilt the project but it did not work either. So again, I just repeat the process by closing the visual studio, rebuild and run 2 times (also I went to the error file just viewed it) and it works fine. I don't know what differences it made but it works when you repeat the process.

Edit: The error is still repeating. I just use the Factory Reset when the error occurs.

humbert
  • 49
  • 5
0

There are fixed minor-version editions of VS available, for example "2022 LTSC 17.2".

Install it parallel to your current VS or exclusively.

https://learn.microsoft.com/en-us/visualstudio/releases/2022/release-history#evergreen-bootstrappers

Direct downloads:

I prefer this over the modification of your 17.3 installation.

It also appears with a different name, so it's easy to distinguish.

start menu enter image description here
VS installer enter image description here
juwens
  • 3,729
  • 4
  • 31
  • 39
0

I had the exact same issue with my Xamarin forms solution, after upgrading from 17.2 to 17.3. Today I installed 17.3.2. A dozen builds later and it seems that the issue has been addressed.