Closed jmajnek closed 6 years ago
It looks like you have some issues with your code:
<UsingTask TaskName="DoNothing" TaskFactory="CodeTaskFactory" AssemblyFile="$(RoslynCodeTaskFactory)">
<ParameterGroup>
<InputString ParameterType="System.String" Required="true" />
<OutputString ParameterType="System.String" Output="true" />
</ParameterGroup>
<Task>
<Reference Include="System.Runtime.Numerics" />
<Reference Include="System.Text.Encoding" />
<Using Namespace="System.Linq" />
<Using Namespace="System.Numerics" />
<Using Namespace="System.Text" />
<Code Type="Fragment" Language="cs">
<![CDATA[
this.OutputString = new BigInteger(Encoding.ASCII.GetBytes("")).ToString().Sum(x => x - '0').ToString();
]]>
</Code>
</Task>
</UsingTask>
System.Numerics
instead of System.Runtime.Numerics
System.Core
System.Numerics
new
keyword in front of BigInteger
With these changes, I was able to run the task but of course it just prints 0
.
<Target Name="TestTarget" AfterTargets="Build">
<DoNothing InputString="foo">
<Output TaskParameter="OutputString" PropertyName="TestBla" />
</DoNothing>
<Message Text="TestBla: '$(TestBla)'" Importance="High" />
</Target>
1>------ Build started: Project: NETStandard.ClassLibrary, Configuration: Debug Any CPU ------
1>NETStandard.ClassLibrary -> D:\RoslynCodeTaskFactory\src\Samples\NETStandard.ClassLibrary\bin\Debug\netstandard2.0\NETStandard.ClassLibrary.dll
1>TestBla: '0'
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
Time Elapsed 00:00:01.410
Hello,
I'm trying to use your CodeTaskFactory like this:
Building the .netstandard2.0 project throws the following exceptions:
Using your nuget package in a .NET 4.7 project and '$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll' as assemblyFile, the inline-tasks works well. Changing to your AssemblyFile returns the same errors.
I'm not sure if this is a bug or something in my code is wrong. Could please help me?
BR Jakob