Skip to content

Commit

Permalink
Fix installation modules csharp (encore) + modules customs
Browse files Browse the repository at this point in the history
  • Loading branch information
JabX committed Sep 4, 2024
1 parent 35ecd2f commit 84c97cc
Show file tree
Hide file tree
Showing 12 changed files with 122 additions and 15 deletions.
10 changes: 9 additions & 1 deletion TopModel.Generator.Csharp/TopModel.Generator.Csharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<PropertyGroup>
<PackageOutputPath>../.nupkg</PackageOutputPath>
<Version>1.0.2</Version>
<Version>1.0.3</Version>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<Authors>JabX</Authors>
<Description>Générateurs C# pour TopModel</Description>
Expand Down Expand Up @@ -56,5 +56,13 @@
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<None Include="build\**">
<Pack>true</Pack>
<PackageCopyToOutput>false</PackageCopyToOutput>
<PackagePath>build\</PackagePath>
</None>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project>
<Target Name="CopyConfigFile" BeforeTargets="BeforeBuild">
<ItemGroup>
<ConfigFileToCopy Include="$(MSBuildThisFileDirectory)../contentFiles/csharp.config.json" />
</ItemGroup>
<Copy SourceFiles="@(ConfigFileToCopy)" DestinationFolder="$(OutputPath)" SkipUnchangedFiles="true" UseHardlinksIfPossible="false" />
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<PropertyGroup>
<PackageOutputPath>../.nupkg</PackageOutputPath>
<Version>1.0.2</Version>
<Version>1.0.3</Version>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<Authors>JabX;gideruette</Authors>
<Description>Générateurs JS/TS pour TopModel</Description>
Expand Down Expand Up @@ -52,5 +52,13 @@
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<None Include="build\**">
<Pack>true</Pack>
<PackageCopyToOutput>false</PackageCopyToOutput>
<PackagePath>build\</PackagePath>
</None>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project>
<Target Name="CopyConfigFile" BeforeTargets="BeforeBuild">
<ItemGroup>
<ConfigFileToCopy Include="$(MSBuildThisFileDirectory)../contentFiles/javascript.config.json" />
</ItemGroup>
<Copy SourceFiles="@(ConfigFileToCopy)" DestinationFolder="$(OutputPath)" SkipUnchangedFiles="true" UseHardlinksIfPossible="false" />
</Target>
</Project>
10 changes: 9 additions & 1 deletion TopModel.Generator.Jpa/TopModel.Generator.Jpa.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<PropertyGroup>
<PackageOutputPath>../.nupkg</PackageOutputPath>
<Version>1.0.2</Version>
<Version>1.0.3</Version>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<Authors>gideruette</Authors>
<Description>Générateurs Java/JPA pour TopModel</Description>
Expand Down Expand Up @@ -53,4 +53,12 @@
</Content>
</ItemGroup>

<ItemGroup>
<None Include="build\**">
<Pack>true</Pack>
<PackageCopyToOutput>false</PackageCopyToOutput>
<PackagePath>build\</PackagePath>
</None>
</ItemGroup>

</Project>
8 changes: 8 additions & 0 deletions TopModel.Generator.Jpa/build/TopModel.Generator.Jpa.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project>
<Target Name="CopyConfigFile" BeforeTargets="BeforeBuild">
<ItemGroup>
<ConfigFileToCopy Include="$(MSBuildThisFileDirectory)../contentFiles/jpa.config.json" />
</ItemGroup>
<Copy SourceFiles="@(ConfigFileToCopy)" DestinationFolder="$(OutputPath)" SkipUnchangedFiles="true" UseHardlinksIfPossible="false" />
</Target>
</Project>
10 changes: 9 additions & 1 deletion TopModel.Generator.Sql/TopModel.Generator.Sql.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<PropertyGroup>
<PackageOutputPath>../.nupkg</PackageOutputPath>
<Version>1.0.2</Version>
<Version>1.0.3</Version>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<Authors>JabX;gideruette</Authors>
<Description>Générateurs SQL pour TopModel</Description>
Expand Down Expand Up @@ -53,4 +53,12 @@
</Content>
</ItemGroup>

<ItemGroup>
<None Include="build\**">
<Pack>true</Pack>
<PackageCopyToOutput>false</PackageCopyToOutput>
<PackagePath>build\</PackagePath>
</None>
</ItemGroup>

</Project>
8 changes: 8 additions & 0 deletions TopModel.Generator.Sql/build/TopModel.Generator.Sql.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project>
<Target Name="CopyConfigFile" BeforeTargets="BeforeBuild">
<ItemGroup>
<ConfigFileToCopy Include="$(MSBuildThisFileDirectory)../contentFiles/sql.config.json" />
</ItemGroup>
<Copy SourceFiles="@(ConfigFileToCopy)" DestinationFolder="$(OutputPath)" SkipUnchangedFiles="true" UseHardlinksIfPossible="false" />
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<PropertyGroup>
<PackageOutputPath>../.nupkg</PackageOutputPath>
<Version>1.0.2</Version>
<Version>1.0.3</Version>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<Authors>gideruette</Authors>
<Description>Générateurs de traductions manquantes pour TopModel</Description>
Expand Down Expand Up @@ -53,4 +53,12 @@
</Content>
</ItemGroup>

<ItemGroup>
<None Include="build\**">
<Pack>true</Pack>
<PackageCopyToOutput>false</PackageCopyToOutput>
<PackagePath>build\</PackagePath>
</None>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project>
<Target Name="CopyConfigFile" BeforeTargets="BeforeBuild">
<ItemGroup>
<ConfigFileToCopy Include="$(MSBuildThisFileDirectory)../contentFiles/translation.config.json" />
</ItemGroup>
<Copy SourceFiles="@(ConfigFileToCopy)" DestinationFolder="$(OutputPath)" SkipUnchangedFiles="true" UseHardlinksIfPossible="false" />
</Target>
</Project>
45 changes: 36 additions & 9 deletions TopModel.Generator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Microsoft.Extensions.Logging;
using NuGet.Common;
using NuGet.Packaging;
using NuGet.Packaging.Core;
using NuGet.Protocol;
using NuGet.Protocol.Core.Types;
using NuGet.Versioning;
Expand Down Expand Up @@ -289,11 +290,15 @@ void HandleFile(FileInfo file)

if (returnCode == 0)
{
generators.AddRange(new DirectoryInfo(Path.Combine(Path.GetFullPath(cg, new FileInfo(fullName).DirectoryName!), "bin"))
.GetFiles($"{cg.Split('/').Last()}.dll", SearchOption.AllDirectories)
var assemblies = new DirectoryInfo(Path.Combine(Path.GetFullPath(cg, new FileInfo(fullName).DirectoryName!), "bin"))
.GetFiles($"*.dll", SearchOption.AllDirectories)
.Where(a => a.FullName.Contains(framework) && a.Name != "TopModel.Generator.Core.dll")
.DistinctBy(a => a.Name)
.Select(f => Assembly.LoadFrom(f.FullName))
.ToList();

generators.AddRange(assemblies
.Where(a => a.ManifestModule.Name.ToLower() == $"{cg.Split('/').Last().ToLower()}.dll")
.SelectMany(a => a.GetExportedTypes())
.Where(t => GetIGenRegInterface(t) != null));
}
Expand Down Expand Up @@ -395,15 +400,37 @@ void HandleFile(FileInfo file)
packageReader.ExtractFile(file, Path.Combine(moduleFolder, file.Split('/').Last()), NullLogger.Instance);
}

foreach (var otherDep in dependencies.Where(d => d.Id != "TopModel.Generator.Core"))
var installedDependencies = new List<string>();
dependencies = dependencies.Where(d => d.Id != "TopModel.Generator.Core");

while (dependencies.Any())
{
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"))
var newDeps = new List<PackageDependency>();
foreach (var otherDep in dependencies)
{
packageReaderDep.ExtractFile(file, Path.Combine(moduleFolder, file.Split('/').Last()), NullLogger.Instance);
using var packageStreamDep = new MemoryStream();
await nugetResource.CopyNupkgToStreamAsync(otherDep.Id, otherDep.VersionRange.MinVersion, packageStreamDep, nugetCache, NullLogger.Instance, ct);

using var packageReaderDep = new PackageArchiveReader(packageStreamDep);
var file = packageReaderDep.GetFiles().SingleOrDefault(f => f.StartsWith($"lib/{framework}") && f.EndsWith(".dll") && !f.EndsWith(".resources.dll"));
if (file != null)
{
packageReaderDep.ExtractFile(file, Path.Combine(moduleFolder, file.Split('/').Last()), NullLogger.Instance);

installedDependencies.Add(otherDep.Id);

var nuspecReaderDep = await packageReaderDep.GetNuspecReaderAsync(ct);
if (nuspecReaderDep.GetDependencyGroups().Any())
{
newDeps.AddRange(nuspecReaderDep.GetDependencyGroups()
.Single(dg => dg.TargetFramework.ToString() == framework)
.Packages
.Where(dep => !installedDependencies.Contains(dep.Id)));
}
}
}

dependencies = newDeps;
}

hasInstalled = true;
Expand Down Expand Up @@ -585,4 +612,4 @@ void HandleFile(FileInfo file)
return 1;
}

return returnCode;
return returnCode;
2 changes: 1 addition & 1 deletion TopModel.Generator/TopModel.Generator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<PackAsTool>true</PackAsTool>
<PackageOutputPath>../.nupkg</PackageOutputPath>
<ToolCommandName>modgen</ToolCommandName>
<Version>2.0.1</Version>
<Version>2.0.2</Version>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<Authors>JabX;gideruette</Authors>
<Description>Générateur de modèle TopModel.</Description>
Expand Down

0 comments on commit 84c97cc

Please sign in to comment.