Skip to content

Commit

Permalink
Fix install module csharp
Browse files Browse the repository at this point in the history
  • Loading branch information
JabX committed Sep 4, 2024
1 parent e89d85a commit 35ecd2f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
26 changes: 19 additions & 7 deletions TopModel.Generator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -382,18 +382,30 @@ void HandleFile(FileInfo file)
using var packageReader = new PackageArchiveReader(packageStream);
var nuspecReader = await packageReader.GetNuspecReaderAsync(ct);

File.WriteAllText(
Path.Combine(moduleFolder, "min-version"),
nuspecReader.GetDependencyGroups()
.Single(dg => dg.TargetFramework.ToString() == framework)
.Packages
.Single(d => d.Id == "TopModel.Generator.Core").VersionRange.MinVersion!.ToString());
var dependencies = nuspecReader.GetDependencyGroups()
.Single(dg => dg.TargetFramework.ToString() == framework)
.Packages;

var minVersion = dependencies.Single(d => d.Id == "TopModel.Generator.Core").VersionRange.MinVersion!.ToString();

File.WriteAllText(Path.Combine(moduleFolder, "min-version"), minVersion);

foreach (var file in packageReader.GetFiles().Where(f => f == $"lib/{framework}/{dep.FullName}.dll" || f.EndsWith("config.json")))
{
packageReader.ExtractFile(file, Path.Combine(moduleFolder, file.Split('/').Last()), NullLogger.Instance);
}

foreach (var otherDep in dependencies.Where(d => d.Id != "TopModel.Generator.Core"))
{
using var packageStreamDep = new MemoryStream();
await nugetResource.CopyNupkgToStreamAsync(otherDep.Id, otherDep.VersionRange.MinVersion, packageStreamDep, nugetCache, NullLogger.Instance, ct);
using var packageReaderDep = new PackageArchiveReader(packageStreamDep);
foreach (var file in packageReaderDep.GetFiles().Where(f => f == $"lib/netstandard2.0/{otherDep.Id}.dll"))
{
packageReaderDep.ExtractFile(file, Path.Combine(moduleFolder, file.Split('/').Last()), NullLogger.Instance);
}
}

hasInstalled = true;
logger.LogInformation($"({dep.ConfigKey}) Installation de {dep.FullName}@{dep.Version} terminée avec succès.");
}
Expand All @@ -413,7 +425,7 @@ void HandleFile(FileInfo file)
continue;
}

generators.AddRange(Assembly.LoadFrom(Path.Combine(moduleFolder, $"{dep.FullName}.dll")).GetExportedTypes().Where(t => GetIGenRegInterface(t) != null));
generators.AddRange(Directory.GetFiles(moduleFolder, "*.dll").SelectMany(a => Assembly.LoadFrom(a).GetExportedTypes().Where(t => GetIGenRegInterface(t) != null)));
resolvedConfigKeys.Add(dep.ConfigKey, dep.Version);
}
}
Expand Down
4 changes: 2 additions & 2 deletions TopModel.Generator/TopModel.Generator.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0;net6.0</TargetFrameworks>
<LangVersion>12</LangVersion>
<OutputType>Exe</OutputType>
<Nullable>enable</Nullable>
Expand All @@ -13,7 +13,7 @@
<PackAsTool>true</PackAsTool>
<PackageOutputPath>../.nupkg</PackageOutputPath>
<ToolCommandName>modgen</ToolCommandName>
<Version>2.0.0</Version>
<Version>2.0.1</Version>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<Authors>JabX;gideruette</Authors>
<Description>Générateur de modèle TopModel.</Description>
Expand Down

0 comments on commit 35ecd2f

Please sign in to comment.