C#C
C#3y ago
Chik3r

Custom MSBuild task fails to load `System.Runtime`

Hi, I'm making a custom MSBuild task that needs to load images and I was using ImageSharp for that. Before, I was targetting net6.0 and it worked when using dotnet build or Rider, but I now had to change to netstandard2.0 as I need to support VS and forgot that VS only likes netstandard. After I changed to netstandard2.0, a method using ImageSharp started to throw the following exception while running the task, but only from VS (it still works when using dotnet build):
Could not load file or assembly 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
   at tModLoader.BuildTools.ModFile.ContentConverters.ToRaw(Stream src, Stream dst)
   at tModLoader.BuildTools.ModFile.ContentConverters.Convert(String& resourceName, FileStream src, MemoryStream dst) in C:\Users\ikerv\Documents\Programming\tModLoader\tModLoader\BuildTools\ModFile\ContentConverters.cs:line 15
   at tModLoader.BuildTools.Tasks.PackageModFile.AddResource(TmodFile tmodFile, String resourcePath) in C:\Users\ikerv\Documents\Programming\tModLoader\tModLoader\BuildTools\Tasks\PackageModFile.cs:line 253
   at tModLoader.BuildTools.Tasks.PackageModFile.<>c__DisplayClass42_0.<Run>b__1(String resource) in C:\Users\ikerv\Documents\Programming\tModLoader\tModLoader\BuildTools\Tasks\PackageModFile.cs:line 109
   at System.Threading.Tasks.Parallel.<>c__DisplayClass17_0`1.<ForWorker>b__1()
   at System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask)
   at System.Threading.Tasks.Task.<>c__DisplayClass176_0.<ExecuteSelfReplicating>b__0(Object <p0>)
Was this page helpful?