Skip to content

Commit 2203deb

Browse files
committed
Fix compiler cache
1 parent de64b14 commit 2203deb

1 file changed

Lines changed: 19 additions & 5 deletions

File tree

Src/FastData.Generator.Template/Helpers/TemplateManager.cs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,26 @@ private string ExecuteCompiledTemplate<TKey>(OutputWriter<TKey> writer, string c
146146

147147
private static IEnumerable<MetadataReference> GetMetadataReferences(TemplateGenerator generator, TemplateSettings settings, string[] references)
148148
{
149-
HashSet<string> referencePaths = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
150-
AddReferencePaths(referencePaths, references);
151-
AddReferencePaths(referencePaths, generator.Refs);
152-
AddReferencePaths(referencePaths, settings.Assemblies);
149+
HashSet<string> paths = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
150+
AddReferencePaths(paths, references);
151+
AddReferencePaths(paths, generator.Refs);
152+
AddReferencePaths(paths, settings.Assemblies);
153153

154-
return referencePaths.Select(r => MetadataReference.CreateFromFile(r));
154+
// Add standard references for .NET
155+
string? dotNetDir = Path.GetDirectoryName(typeof(object).Assembly.Location);
156+
157+
if (dotNetDir == null)
158+
throw new InvalidOperationException("Unable to find .NET runtime");
159+
160+
paths.Add(Path.Combine(dotNetDir, "System.Runtime.dll"));
161+
paths.Add(Path.Combine(dotNetDir, "System.Collections.dll"));
162+
paths.Add(Path.Combine(dotNetDir, "System.Collections.NonGeneric.dll"));
163+
paths.Add(Path.Combine(dotNetDir, "System.Linq.dll"));
164+
paths.Add(Path.Combine(dotNetDir, "netstandard.dll"));
165+
166+
paths.Add(Path.Combine(AppContext.BaseDirectory, "System.CodeDom.dll"));
167+
168+
return paths.Select(r => MetadataReference.CreateFromFile(r));
155169
}
156170

157171
private static void AddReferencePaths(HashSet<string> referencePaths, ICollection<string> references)

0 commit comments

Comments
 (0)