Fix strange scripting errors.

This commit is contained in:
Zontreck 2023-08-10 22:52:14 -07:00
parent 035ab6e830
commit fdbdf0ce62
4 changed files with 15 additions and 3 deletions

Binary file not shown.

View file

@ -94,6 +94,7 @@
<OutputPath>../../bootstrap/debug/</OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
</Options>
</Configuration>
<Configuration name="Release">
@ -104,11 +105,12 @@
</Options>
</Configuration>
<PackageReference name="Microsoft.CodeAnalysis" version="4.6.0"/>
<PackageReference name="Microsoft.CodeAnalysis.CSharp" version="4.6.0"/>
<PackageReference name="Microsoft.CodeAnalysis.CSharp.Scripting" version="4.6.0"/>
<PackageReference name="System.Diagnostics.Process" version="4.3.0"/>
<Reference name="System.Diagnostics"/>
<Reference name="System.Diagnostics.Process"/>
</Project>
</Solution>

View file

@ -696,7 +696,7 @@ public abstract class VSGenericTarget : ITarget
string outputFile = Path.Combine(project.Path, node.OutputName);
ps.WriteLine(" <Target Name=\"Prebuild\" BeforeTargets=\"PreBuildEvent\">");
ps.WriteLine($" <Exec Command=\"'dotnet' '$(ProjectDir){pathText}' '$(ProjectDir){node.Name}' '$(ProjectDir){node.OutputName}' '{node.Libraries}' \" />");
ps.WriteLine($" <Exec Command='dotnet \"$(SolutionDir){pathText}\" \"$(ProjectDir){node.Name}\" \"$(ProjectDir){node.OutputName}\" \"{node.Libraries}\"' />");
ps.WriteLine($" </Target>");
}
}

View file

@ -14,16 +14,26 @@ namespace SnapWrap
string output = args[1];
var customImports = args[2].Split("..");
if (customImports.Length == 0) customImports = new string[3] { "System", "System.Diagnostics.Process", "System.IO" };
try
{
var inputCode = File.ReadAllText(input);
var options = ScriptOptions.Default
.WithReferences(AppDomain.CurrentDomain.GetAssemblies()) // Add necessary assemblies
.WithReferences(typeof(Process).Assembly,
typeof(Console).Assembly
)
.WithOptimizationLevel(Microsoft.CodeAnalysis.OptimizationLevel.Release)
.WithImports(customImports)
.WithAllowUnsafe(true);
Console.WriteLine("Run Script: " + input);
Console.WriteLine("Script Length: " + inputCode.Length);
// Capture console output using custom class
using (var consoleOutput = new ConsoleOutput())
{