Skip to content

Commit

Permalink
fix: not generating .NET code on each TF iteration (#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
dotkas authored Mar 11, 2024
1 parent 0a3ec59 commit fbc452d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions lib/nuget-parser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ Will attempt to build dependency graph anyway, but the operation might fail.`);
// Ensure `dotnet` is installed on the system or fail trying.
await dotnet.validate();

// Write a .NET Framework Parser to a temporary directory for validating TargetFrameworks.
const nugetFrameworksParserLocation = nugetFrameworksParser.generate();
await dotnet.restore(nugetFrameworksParserLocation);

// Loop through all TargetFrameworks supplied and generate a dependency graph for each.
const results: DotnetCoreV2Results = [];
for (const decidedTargetFramework of decidedTargetFrameworks) {
// Run `dotnet publish` to create a self-contained publishable binary with included .dlls for assembly version inspection.
Expand All @@ -171,9 +176,9 @@ Will attempt to build dependency graph anyway, but the operation might fail.`);

// Parse the TargetFramework using Nuget.Frameworks itself, instead of trying to reinvent the wheel, thus ensuring
// we have maximum context to use later when building the depGraph.
const location = nugetFrameworksParser.generate();
await dotnet.restore(location);
const response = await dotnet.run(location, [decidedTargetFramework]);
const response = await dotnet.run(nugetFrameworksParserLocation, [
decidedTargetFramework,
]);
const targetFrameworkInfo: TargetFrameworkInfo = JSON.parse(response);
if (targetFrameworkInfo.IsUnsupported) {
throw new InvalidManifestError(
Expand All @@ -187,6 +192,7 @@ Will attempt to build dependency graph anyway, but the operation might fail.`);
publishedProjectDeps,
assemblyVersions,
);

results.push({
dependencyGraph: depGraph,
targetFramework: decidedTargetFramework,
Expand Down
2 changes: 1 addition & 1 deletion lib/nuget-parser/parsers/dotnet-core-v2-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function recursivelyPopulateNodes(

const childId = `${childNode.name}@${childNode.version}`;

// If we're looking at a runtime assembly version for self-contained dlls, overwrite the dependency version
// If we're looking at a runtime assembly version for self-contained dlls, overwrite the dependency version
// we've found in the graph with those from the runtime assembly, as they take precedence.
let assemblyVersion = version;
// The RuntimeAssembly type contains the name with a .dll suffix, as this is how .NET represents them in the
Expand Down

0 comments on commit fbc452d

Please sign in to comment.