Skip to content

Commit

Permalink
Make builder work with the Net48 property
Browse files Browse the repository at this point in the history
  • Loading branch information
quajak committed Nov 6, 2021
1 parent 56e1025 commit 289b9a1
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 15 deletions.
2 changes: 1 addition & 1 deletion source/Cosmos.Build.Builder/BuildTasks/BuildTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public BuildTask(

if (vsixBuild)
{
_properties["VSIX"] = "True";
_properties["Net48"] = "True";
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion source/Cosmos.Build.Builder/BuildTasks/PackTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public PackTask(
IMSBuildService msBuildService,
string projectFilePath,
string packageOutputPath,
string packageVersionLocalBuildSuffix)
string packageVersionLocalBuildSuffix,
bool vsixBuild = false)
: base(msBuildService)
{
ProjectFilePath = projectFilePath;
Expand All @@ -33,6 +34,11 @@ public PackTask(
["PackageOutputPath"] = packageOutputPath,
["PackageVersionLocalBuildSuffix"] = packageVersionLocalBuildSuffix
};

if (vsixBuild)
{
_properties["Net48"] = "True";
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private static void WaitForExit(Process process)
string error = "";
foreach (var item in Lines)
{
if (item.Contains("error"))
if (item.ToLower().Contains("error"))
{
error += item + "\n";
}
Expand Down
14 changes: 12 additions & 2 deletions source/Cosmos.Build.Builder/BuildTasks/RestoreTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,24 @@ internal class RestoreTask : MSBuildTargetBuildTaskBase

public override IEnumerable<string> Targets { get { yield return RestoreTaskName; } }

protected override IReadOnlyDictionary<string, string> Properties => null;
protected override IReadOnlyDictionary<string, string> Properties => _properties;
private readonly Dictionary<string, string> _properties;

public RestoreTask(
IMSBuildService msBuildService,
string projectFilePath)
string projectFilePath,
bool vsixBuild = false)
: base(msBuildService)
{
ProjectFilePath = projectFilePath;

if (vsixBuild)
{
_properties = new Dictionary<string, string>
{
["Net48"] = "True"
};
}
}
}
}
44 changes: 34 additions & 10 deletions source/Cosmos.Build.Builder/CosmosBuildDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void CleanPackage(string aPackage)

// Restore Build.sln

yield return new RestoreTask(_msBuildService, buildSlnPath);
yield return new RestoreTask(_msBuildService, buildSlnPath, true);

// Build Build.sln

Expand All @@ -97,18 +97,28 @@ void CleanPackage(string aPackage)
var il2cpuProjectPath = Path.Combine(il2cpuSourceDir, "IL2CPU", "IL2CPU.csproj");
var il2cpuPublishPath = Path.Combine(vsipDir, "IL2CPU");

yield return new RestoreTask(_msBuildService, il2cpuProjectPath);
yield return new PublishTask(_msBuildService, il2cpuProjectPath, il2cpuPublishPath);

// Pack build system and kernel assemblies

var cosmosPackageProjects = new List<string>()
{
"Cosmos.Build.Tasks",
};

foreach (var task in PackProject(cosmosPackageProjects, new List<string>(), true))
{
yield return task;
}

cosmosPackageProjects = new List<string>()
{
"Cosmos.Core_Plugs", // we ned to restore il2cpu.debug.

"Cosmos.Common",

"Cosmos.Core",
"Cosmos.Core_Plugs",
"Cosmos.Core_Asm",

"Cosmos.HAL2",
Expand All @@ -125,15 +135,9 @@ void CleanPackage(string aPackage)
"IL2CPU.API"
};

var packageProjectPaths = cosmosPackageProjects.Select(p => Path.Combine(cosmosSourceDir, p));
packageProjectPaths = packageProjectPaths.Concat(il2cpuPackageProjects.Select(p => Path.Combine(il2cpuSourceDir, p)));

var packagesDir = Path.Combine(vsipDir, "packages");
var packageVersionLocalBuildSuffix = DateTime.Now.ToString("yyyyMMddhhmmss");

foreach (var projectPath in packageProjectPaths)
foreach (var task in PackProject(cosmosPackageProjects, il2cpuPackageProjects, false))
{
yield return new PackTask(_msBuildService, projectPath, packagesDir, packageVersionLocalBuildSuffix);
yield return task;
}

var cosmosSetupDir = Path.Combine(_cosmosDir, "setup");
Expand Down Expand Up @@ -164,6 +168,26 @@ void CleanPackage(string aPackage)
xKey.SetValue("DevKit", _cosmosDir);
}
}

IEnumerable<IBuildTask> PackProject(List<string> cosmosProjects, List<string> il2cpuProjects, bool targetNet48)
{
var packageProjectPaths = cosmosProjects.Select(p => Path.Combine(cosmosSourceDir, p));
packageProjectPaths = packageProjectPaths.Concat(il2cpuProjects.Select(p => Path.Combine(il2cpuSourceDir, p)));

var packagesDir = Path.Combine(vsipDir, "packages");
var packageVersionLocalBuildSuffix = DateTime.Now.ToString("yyyyMMddhhmmss");

var restore = true;
foreach (var projectPath in packageProjectPaths)
{
if (restore)
{
yield return new RestoreTask(_msBuildService, projectPath, targetNet48);
restore = false;
}
yield return new PackTask(_msBuildService, projectPath, packagesDir, packageVersionLocalBuildSuffix, targetNet48);
}
}
}
}
}
4 changes: 4 additions & 0 deletions source/Cosmos.VS.DebugEngine/Cosmos.VS.DebugEngine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
<RuntimeIdentifier>win-x32</RuntimeIdentifier>
</PropertyGroup>

<PropertyGroup>
<Net48>True</Net48>
</PropertyGroup>

<ItemGroup>
<Content Include="Resources\Icon.png" IncludeInVSIX="True" />
<Content Include="Cosmos.DebugEngine.pkgdef" CopyToOutputDirectory="Always" IncludeInVSIX="True" />
Expand Down

0 comments on commit 289b9a1

Please sign in to comment.