dotnet / dotnet/msbuild

Add documentation for the risks for version incompatibilities between msbuild and a plugin dependencies

Open
#10,213 8 comments 0 reactions 0 assignees View on GitHub
Area: Documentation Priority:2 triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 8h
Merged PRs (30d)
141

Description

### Description:

We have encountered an issue, when MSBuild was using System.CodeDom net8.0 and [the source project](https://github.com/MessagePack-CSharp/MessagePack-CSharp/pull/1832) had System.CodeDom net6.0 package dependency that was copied in the output folder.
During the _**runtime**_ it caused the exception:

```
targets/Microsoft.NET.GenerateAssemblyInfo.targets: (199, 5): The "WriteCodeFragment" task failed unexpectedly.
System.IO.FileLoadException: Could not load file or assembly 'System.CodeDom, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. Could not find or load a specific file. (0x80131621)
File name: 'System.CodeDom, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
---> System.IO.FileLoadException: Could not load file or assembly 'System.CodeDom, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
at System.Reflection.Assembly.LoadFrom(String assemblyFile)
at Microsoft.Build.Locator.MSBuildLocator.<>c__DisplayClass15_0.g__TryLoadAssembly|3(AssemblyName assemblyName)
at Microsoft.Build.Locator.MSBuildLocator.<>c__DisplayClass15_0.b__2(AssemblyLoadContext _, AssemblyName assemblyName)
at System.Runtime.Loader.AssemblyLoadContext.GetFirstResolvedAssemblyFromResolvingEvent(AssemblyName assemblyName)
at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingEvent(AssemblyName assemblyName)
at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingResolvingEvent(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
at Microsoft.Build.Tasks.WriteCodeFragment.GenerateCode(String& extension)
at Microsoft.Build.Tasks.WriteCodeFragment.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask)
========================================
at MessagePack.Generator.MessagepackCompiler.OpenMSBuildProjectAsync(String projectPath, CancellationToken cancellationToken) in /home/vsts/work/1/s/src/MessagePack.Generator/MessagepackCompiler.cs:line 96
at MessagePack.Generator.MessagepackCompiler.RunAsync(String input, String output, String conditionalSymbol, String resolverName, String namespace, Boolean useMapMode, String multipleIfDirectiveOutputSymbols, String[] externalIgnoreTypeNames) in /home/vsts/work/1/s/src/MessagePack.Generator/MessagepackCompiler.cs:line 63
at ConsoleAppFramework.WithFilterInvoker.RunCore(ConsoleAppContext _)
at ConsoleAppFramework.WithFilterInvoker.InvokeAsync()
at ConsoleAppFramework.ConsoleAppEngine.RunCore(Type type, MethodInfo methodInfo, Object instance, String[] args, Int32 argsOffset)
at ConsoleAppFramework.ConsoleAppEngine.RunCore(Type type, MethodInfo methodInfo, Object instance, String[] args, Int32 argsOffset)

```

### Suggested action

Document the versions that MSBuild binds to for each feature-band release and publish it as a part of documentation.
The ticket [#9312](https://github.com/dotnet/msbuild/issues/9312) can be used as a basement for that.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.