C
C#7mo ago
ascpixi

`RoslynCodeTaskFactory` using an ancient version of .NET...?

Hiya all! :cathi: I'm trying to define an inline task with RoslynCodeTaskFactory, but it seems like the corelib that the factory uses is a bit old - for example, there's no System.Range, you can't split by strings (only by chars!), and even ProcessStartInfo.ArgumentList doesn't exist. How can I tell the factory to use a more reasonable version? I'm defining the task like this:
<UsingTask TaskName="Script"
TaskFactory="RoslynCodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll"
>
<ParameterGroup>
<Content ParameterType="System.String" Required="True"/>
<In ParameterType="System.String" Required="False"/>
</ParameterGroup>

<Task>
<Using Namespace="System"/>
<Using Namespace="System.Diagnostics"/>
<Using Namespace="System.Collections.Generic"/>

<Code Type="Fragment" Language="cs">
<![CDATA[
(lots of code... above Discord's character limit)
]]>
</Code>
</Task>
</UsingTask>
<UsingTask TaskName="Script"
TaskFactory="RoslynCodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll"
>
<ParameterGroup>
<Content ParameterType="System.String" Required="True"/>
<In ParameterType="System.String" Required="False"/>
</ParameterGroup>

<Task>
<Using Namespace="System"/>
<Using Namespace="System.Diagnostics"/>
<Using Namespace="System.Collections.Generic"/>

<Code Type="Fragment" Language="cs">
<![CDATA[
(lots of code... above Discord's character limit)
]]>
</Code>
</Task>
</UsingTask>
3 Replies
ascpixi
ascpixiOP7mo ago
i'm doing dotnet publish under linux, if that matters
reflectronic
reflectronic7mo ago
https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild-roslyncodetaskfactory?view=vs-2022
RoslynCodeTaskFactory tasks target .NET Standard and can work on .NET Framework and .NET Core runtimes as well as other platforms such as Linux and macOS.
you cannot change it. otherwise, the code would not in msbuild.exe or Visual Studio
ascpixi
ascpixiOP7mo ago
awh, that sucks, alright :(
Want results from more Discord servers?
Add your server