Skip to content

Commit 04b386b

Browse files
authored
Fixes for compiling multi contracts in single csproj (#953)
1 parent 7add5a9 commit 04b386b

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/Neo.Compiler.CSharp/CompilationEngine.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,9 @@ public Compilation GetCompilation(string csproj)
172172
{
173173
string folder = Path.GetDirectoryName(csproj)!;
174174
string obj = Path.Combine(folder, "obj");
175+
string binSc = Path.Combine(Path.Combine(folder, "bin"), "sc");
175176
HashSet<string> sourceFiles = Directory.EnumerateFiles(folder, "*.cs", SearchOption.AllDirectories)
176-
.Where(p => !p.StartsWith(obj))
177+
.Where(p => !p.StartsWith(obj) && !p.StartsWith(binSc))
177178
.GroupBy(Path.GetFileName)
178179
.Select(g => g.First())
179180
.ToHashSet(StringComparer.OrdinalIgnoreCase);

src/Neo.Compiler.CSharp/Program.cs

+16-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,22 @@ private static int ProcessSources(Options options, string folder, string[] sourc
138138

139139
private static int ProcessOutputs(Options options, string folder, List<CompilationContext> contexts)
140140
{
141-
return contexts.Select(p => ProcessOutput(options, folder, p)).Any(p => p != 1) ? 0 : 1;
141+
int result = 0;
142+
List<Exception> exceptions = new();
143+
foreach (CompilationContext context in contexts)
144+
try
145+
{
146+
if (ProcessOutput(options, folder, context) != 0)
147+
result = 1;
148+
}
149+
catch (Exception e)
150+
{
151+
result = 1;
152+
exceptions.Add(e);
153+
}
154+
foreach (Exception e in exceptions)
155+
Console.Error.WriteLine(e.ToString());
156+
return result;
142157
}
143158

144159
private static int ProcessOutput(Options options, string folder, CompilationContext context)

0 commit comments

Comments
 (0)