Skip to content

Commit

Permalink
Remove .sln files and use .slnf files (solution filters) generated fr…
Browse files Browse the repository at this point in the history
…om a single Serenity.sln at root for partial builds. Use Serenity.sln instead of Serene.sln.
  • Loading branch information
volkanceylan committed Oct 25, 2024
1 parent b0f6d1c commit 873a3ad
Show file tree
Hide file tree
Showing 19 changed files with 371 additions and 431 deletions.
26 changes: 6 additions & 20 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,17 @@ jobs:
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore Dependencies
run: dotnet restore
working-directory: "src"

- name: dotnet build
run: dotnet build --no-restore /p:SkipNodeScripts=true
working-directory: "src"

- name: dotnet test
run: dotnet test --no-build --verbosity normal
working-directory: "src"

js-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true

- name: setup node
uses: actions/setup-node@v4
with:
node-version: '20'

- name: dotnet build Serenity.sln
run: dotnet build /p:SkipNodeScripts=true

- name: dotnet test
run: dotnet test --no-build --verbosity normal

- name: pnpm install
uses: ./.github/actions/pnpm-install

Expand Down
211 changes: 211 additions & 0 deletions Serenity.sln

Large diffs are not rendered by default.

99 changes: 65 additions & 34 deletions build/_build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ var target = Argument("target", "Pack");
if (target == "")
target = "Pack";

var localPush = Argument("localpush", false);

var configuration = Argument("configuration", "Release");
var nupkgDir = System.IO.Path.Combine(System.IO.Path.GetFullPath("."), ".nupkg");
var root = System.IO.Path.GetFullPath(@"..");
Expand Down Expand Up @@ -89,7 +91,7 @@ Action fixNugetCache = delegate() {
if (System.IO.Directory.Exists(dir))
System.IO.Directory.Delete(dir, true);
}

NuGetPush(package, new NuGetPushSettings {
Source = myPackagesDir
});
Expand All @@ -100,11 +102,13 @@ Action myPush = delegate() {
foreach (var package in System.IO.Directory.GetFiles(nupkgDir, "*.nupkg"))
{
NuGetPush(package, new NuGetPushSettings {
Source = "https://api.nuget.org/v3/index.json"
Source = "https://api.nuget.org/v3/index.json",
SkipDuplicate = true
});

NuGetPush(package, new NuGetPushSettings {
Source = "serenity.is"
Source = "serenity.is",
SkipDuplicate = true
});
}
};
Expand All @@ -126,6 +130,35 @@ Action<Dictionary<string, string>, JObject, string> addDeps = (p, deps, fw) => {
};

Action pack = () => {
// https://github.com/NuGet/Home/issues/7001
var dateTime = new DateTime(2001, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
foreach (var fileInfo in new System.IO.DirectoryInfo(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".nuget")).GetFiles("*.*", System.IO.SearchOption.AllDirectories)) {
if (fileInfo.Exists && fileInfo.LastWriteTimeUtc < dateTime)
{
try
{
fileInfo.LastWriteTimeUtc = dateTime;
}
catch (Exception)
{
Console.WriteLine(String.Format("Could not reset {LastWriteTime} {File} in nuspec",
nameof(fileInfo.LastWriteTimeUtc),
fileInfo.FullName));
}
}
}
myPack("Serenity.Net.Core", null, null);
myPack("Serenity.Net.Data", null, null);
myPack("Serenity.Net.Entity", null, null);
myPack("Serenity.Net.Services", null, null);
myPack("Serenity.Net.Web", null, null);
myPack("Serenity.Net.CodeGenerator", "sergen", null);
myPack("Serenity.Assets", null, null);
myPack("../packages/corelib", "Serenity.Corelib", "Serenity.Corelib");
};

Task("Clean")
.Does(() =>
{
Expand All @@ -140,7 +173,7 @@ Task("Restore")
.IsDependentOn("Clean")
.Does(context =>
{
var dotnetSln = System.IO.Path.Combine(src, "Serenity.Net.sln");
var dotnetSln = System.IO.Path.Combine(src, "Serenity.Net.slnf");
writeHeader("dotnet restore " + dotnetSln);
var exitCode = StartProcess("dotnet", "restore " + dotnetSln);
if (exitCode > 0)
Expand All @@ -151,8 +184,8 @@ Task("Compile")
.IsDependentOn("Restore")
.Does(context =>
{
writeHeader("Building Serenity.Net.sln");
MSBuild(System.IO.Path.Combine(src, "Serenity.Net.sln"), s => {
writeHeader("Building Serenity.Net.slnf");
MSBuild(System.IO.Path.Combine(src, "Serenity.Net.slnf"), s => {
s.SetConfiguration(configuration);
s.ToolPath = msBuildPath;
s.Verbosity = Verbosity.Minimal;
Expand Down Expand Up @@ -183,42 +216,40 @@ Task("Test")
});

Task("PackOnly")
.Does(() => {
pack();
});

Task("Pack")
.IsDependentOn("Test")
.Does(() =>
{
// https://github.com/NuGet/Home/issues/7001
var dateTime = new DateTime(2001, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
foreach (var fileInfo in new System.IO.DirectoryInfo(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".nuget")).GetFiles("*.*", System.IO.SearchOption.AllDirectories)) {
if (fileInfo.Exists && fileInfo.LastWriteTimeUtc < dateTime)
{
try
{
fileInfo.LastWriteTimeUtc = dateTime;
}
catch (Exception)
{
Console.WriteLine(String.Format("Could not reset {LastWriteTime} {File} in nuspec",
nameof(fileInfo.LastWriteTimeUtc),
fileInfo.FullName));
}
}
}
myPack("Serenity.Net.Core", null, null);
myPack("Serenity.Net.Data", null, null);
myPack("Serenity.Net.Entity", null, null);
myPack("Serenity.Net.Services", null, null);
myPack("Serenity.Net.Web", null, null);
myPack("Serenity.Net.CodeGenerator", "sergen", null);
myPack("Serenity.Assets", null, null);
myPack("../packages/corelib", "Serenity.Corelib", "Serenity.Corelib");
fixNugetCache();
pack();
});

Task("LocalPushOnly")
.Does(() =>
{
fixNugetCache();
});

Task("LocalPush")
.IsDependentOn("Pack")
.WithCriteria(localPush)
.Does(() => {
fixNugetCache();
});

Task("PushOnly")
.Does(() =>
{
myPush();
});

Task("Push")
.IsDependentOn("Pack")
.IsDependentOn("LocalPush")
.Does(() =>
{
myPush();
Expand Down
6 changes: 3 additions & 3 deletions common-features/build/Feature.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<PropertyGroup>
<LangVersion>latest</LangVersion>
<TargetFramework>net8.0</TargetFramework>
<SerenityDir Condition="'$(SerenityDir)' == '' And Exists('$(SolutionDir)Serenity\src\Serenity.Net.sln')">$(SolutionDir)Serenity\</SerenityDir>
<SerenityDir Condition="'$(SerenityDir)' == '' And Exists('$(MSBuildThisFileDirectory)..\src\Serenity.Net.sln')">$(MSBuildThisFileDirectory)..\</SerenityDir>
<SerenityDir Condition="'$(SerenityDir)' == '' And Exists('$(MSBuildThisFileDirectory)..\..\src\Serenity.Net.sln')">$(MSBuildThisFileDirectory)..\..\</SerenityDir>
<SerenityDir Condition="'$(SerenityDir)' == '' And Exists('$(SolutionDir)Serenity\Serenity..sln')">$(SolutionDir)Serenity\</SerenityDir>
<SerenityDir Condition="'$(SerenityDir)' == '' And Exists('$(MSBuildThisFileDirectory)..\Serenity.sln')">$(MSBuildThisFileDirectory)..\</SerenityDir>
<SerenityDir Condition="'$(SerenityDir)' == '' And Exists('$(MSBuildThisFileDirectory)..\..\Serenity.sln')">$(MSBuildThisFileDirectory)..\..\</SerenityDir>
<SerenitySrc Condition="'$(SerenitySrc)' == ''">$(SerenityDir)src\</SerenitySrc>
<SerenityWebProj Condition="'$(SerenityWebProj)' == ''">$(SerenitySrc)Serenity.Net.Web\Serenity.Net.Web.csproj</SerenityWebProj>
<DotNetSergenDir>$(SerenitySrc)Serenity.Net.CodeGenerator\bin\</DotNetSergenDir>
Expand Down
5 changes: 3 additions & 2 deletions common-features/build/shared/FeatureBuild.Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ public static partial class Shared
public static string PackageOutDir => Path.Combine(Root, "build", ".nupkg");
public static string SerenityDir => Path.Combine(Root, "..", "Serenity");
public static string NugetExePath => Path.Combine(SerenityDir, "build", "tools", "NuGet", "NuGet.exe");
public static string SolutionFile => Path.Combine(Src, Path.GetFileName(Root) + ".sln");
private static string SolutionFileBase => Path.Combine(Src, Path.GetFileName(Root));
public static string SolutionFile => File.Exists(SolutionFileBase + ".slnf") ? SolutionFileBase + ".slnf" : SolutionFileBase + ".sln";
public static string PackageBuildProps => Path.Combine(Root, "build", "Package.Build.props");
public static string SerenityPackageBuildProps => Path.Combine(SerenityDir, "build", "Package.Build.props");
public static string DirectoryBuildProps => Path.Combine(Src, "Directory.Build.props");
Expand All @@ -23,7 +24,7 @@ public static string GetTarget(ArgumentReader arguments)
{
Shared.SerenityVersion = arguments.GetString(["serenity-version", "sv"]);
Shared.PackageVersion = arguments.GetString(["version", "v"]);
Shared.LocalPush = arguments.GetBoolean(["local-push", "localpush", "lp"]) ?? true;
Shared.LocalPush = arguments.GetBoolean(["local-push", "localpush", "lp"]) ?? false;
Shared.IsPatch = arguments.GetBoolean(["patch"]) ?? false;
return arguments.GetCommand() ?? "pack";
}
Expand Down
25 changes: 14 additions & 11 deletions common-features/build/shared/FeatureBuild.Targets.Pack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,30 @@ public static partial class Shared
{
public static partial class Targets
{
public static void Pack()
public static void Pack(bool packOnly = false)
{
PatchPackageBuildProps();
if (!packOnly)
{
PatchPackageBuildProps();

UpdateSergen(Src, SerenityVersion);
UpdateSergen(Src, SerenityVersion);

PatchDirectoryBuildProps();
PatchDirectoryBuildProps();

CleanDirectory(PackageOutDir, true);
CleanDirectory(PackageOutDir, true);

if (StartProcess("pnpm", "all", Src) != 0)
ExitWithError("Error while pnpm all " + Src);
if (StartProcess("pnpm", "all", Src) != 0)
ExitWithError("Error while pnpm all " + Src);

if (StartProcess("dotnet", "restore", Src) != 0)
ExitWithError("Error while restoring " + SolutionFile);
if (StartProcess("dotnet", $"restore \"{SolutionFile}\"", Src) != 0)
ExitWithError("Error while restoring " + SolutionFile);
}

if (StartProcess("dotnet", "pack -v minimal " +
if (StartProcess("dotnet", $"pack \"{SolutionFile}\" -v minimal " +
$"-c Release -p:ContinuousIntegrationBuild=true -o \"{PackageOutDir}\"", Src) != 0)
ExitWithError("Error while building solution!");

if (LocalPush)
if (!packOnly && LocalPush)
try
{
var localFeed = GetLocalNugetFeed(create: true);
Expand Down
2 changes: 1 addition & 1 deletion common-features/build/shared/NuGet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private static PackageSource GetLocalNugetFeed(bool create)
public static void PushToRemoteSource(string nupkg, string pushSource)
{
if (StartProcess("dotnet", $"nuget push \"{nupkg}\"" +
" --source \"" + pushSource + "\"", Path.GetDirectoryName(nupkg)) != 0)
" --source \"" + pushSource + "\" --skip-duplicate", Path.GetDirectoryName(nupkg)) != 0)
{
Console.Error.WriteLine("Error while pushing " + Path.GetFileName(nupkg));
Environment.Exit(1);
Expand Down
6 changes: 4 additions & 2 deletions common-features/build/shared/TemplateBuild.Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ namespace Build;

public static partial class Shared
{
public static string NugetExePath => Path.Combine(Root, "Serenity", "build", "tools", "NuGet", "NuGet.exe");
public static string ProjectId => IsStartSharp ? "StartSharp" : "Serene";
public static string ProjectName => ProjectId + ".Web";
public static string ProjectFolder => Path.Combine(Root, "src", ProjectName);
public static string ProjectFile => Path.Combine(ProjectFolder, ProjectName + ".csproj");
public static string PackageJsonFile => Path.Combine(ProjectFolder, "package.json");
public static string SolutionFolder => IsStartSharp ? Root : SerenityFolder;
public static string SolutionFile => IsStartSharp ? Path.Combine(SolutionFolder, ProjectId + ".sln") : Path.Combine(SerenityFolder, "Serenity.sln");
public static string SergenJsonFile => Path.Combine(ProjectFolder, "sergen.json");
public static string TemplateId => IsStartSharp ? "StartCore" : "SereneCore";
public static string VSIXTemplateFolder => Path.Combine(Root, "vsix");
Expand All @@ -27,7 +28,8 @@ public static partial class Shared
public static string TemplateVersion { get; set; }
public static string TemplateZipFolder => Path.Combine(TemporaryFilesRoot, ProjectId);
public static string TemplateZipWebFolder => Path.Combine(TemporaryFilesRoot, ProjectId, ProjectName);
public static string SerenityPackageBuildProps => Path.Combine(Root, "Serenity", "build", "Package.Build.props");
public static string SerenityFolder => IsStartSharp ? Path.Combine(Root, "Serenity") : Path.Combine(Root, "..");
public static string SerenityPackageBuildProps => Path.Combine(SerenityFolder, "build", "Package.Build.props");
public static bool IsPatch { get; set; } = false;
public static bool LocalPush { get; set; } = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ public static void PrepareVSIX()
UpdateSerenityPackages();
UpdateCommonAndProPackages();

if (StartProcess("dotnet", "restore", Root) != 0)
ExitWithError("Error while restoring " + ProjectFile);
if (!File.Exists(SolutionFile))
ExitWithError("Solution file not found: " + SolutionFile);

if (StartProcess("dotnet", $"restore {SolutionFile}", Path.GetDirectoryName(SolutionFile)) != 0)
ExitWithError("Error while restoring " + SolutionFile);

if (StartProcess("dotnet", "build -v minimal -c Release " + ProjectId + ".sln", Root) != 0)
if (StartProcess("dotnet", $"build -v minimal -c Release \"{SolutionFile}\"", Path.GetDirectoryName(SolutionFile)) != 0)
ExitWithError("Error while building solution!");

var projectPackages = ParsePackages(ProjectFile);
Expand Down
7 changes: 4 additions & 3 deletions common-features/build/src/Program.Targets.Push.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
using System.IO;
using System.IO;

namespace Build;

partial class Program
{
public static partial class Targets
{
public static void Push()
public static void Push(bool pushOnly)
{
Shared.Targets.Pack();
if (!pushOnly)
Shared.Targets.Pack();

foreach (var nupkg in Directory.GetFiles(Shared.PackageOutDir, "*.nupkg"))
if (!Shared.IsProPackage(Path.GetFileName(nupkg)))
Expand Down
8 changes: 4 additions & 4 deletions common-features/build/src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ static void Main(string[] args)
Shared.DetermineRoot();

var target = Shared.GetTarget(new(args));
if (target == "pack")
Shared.Targets.Pack();
else if (target == "push")
Targets.Push();
if (target == "pack" || target == "packonly")
Shared.Targets.Pack(packOnly: target == "packonly");
else if (target == "push" || target == "pushonly")
Targets.Push(pushOnly: target == "pushonly");
}
}
}
Loading

0 comments on commit 873a3ad

Please sign in to comment.