Skip to content

Commit 9e7112e

Browse files
committed
tmp: build avalonia nugets without VS2002 installed (only with net6 sdk)
1 parent 5a1fbef commit 9e7112e

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

dirs.proj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@
2424
<ProjectReference Remove="samples/ControlCatalog.Desktop/*.*proj" />
2525
</ItemGroup>
2626

27+
<ItemGroup Condition="$([MSBuild]::IsOsPlatform('Windows')) AND '$(MSBuildRuntimeType)' == 'Core'">
28+
<!--we are building on windows on dotnet core we need to produce win32interop nuget-->
29+
<ProjectReference Include="src/Windows/Avalonia.Win32.Interop/Avalonia.Win32.Interop.csproj" />
30+
</ItemGroup>
31+
32+
<ItemGroup>
33+
<!--some issue building example, shouldn't cause nuget creation problems-->
34+
<ProjectReference Remove="samples\ControlCatalog.Web\ControlCatalog.Web.csproj" />
35+
</ItemGroup>
36+
2737
<ItemGroup>
2838
<PackageReference Include="SlnGen" Version="2.0.40" PrivateAssets="all" />
2939
</ItemGroup>

nukebuild/Build.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,19 @@ IReadOnlyCollection<Output> MsBuildCommon(
146146
ProcessTasks.StartProcess("xcodebuild", args).AssertZeroExitCode();
147147
});
148148

149+
bool IsDotnetCoreOnlyBuild()
150+
{
151+
//avalonia can't build with msbuild from vs 2019 so we need vs 2022
152+
var r = int.Parse(VSWhere("-latest -nologo -property catalog_productLineVersion").First().Text);
153+
return ForceDotNetCoreBuild || (r <= 2019);
154+
}
155+
149156
Target Compile => _ => _
150157
.DependsOn(Clean, CompileNative)
151158
.DependsOn(CompileHtmlPreviewer)
152159
.Executes(async () =>
153160
{
154-
if (Parameters.IsRunningOnWindows)
161+
if (Parameters.IsRunningOnWindows && !IsDotnetCoreOnlyBuild())
155162
MsBuildCommon(Parameters.MSBuildSolution, c => c
156163
.SetProcessArgumentConfigurator(a => a.Add("/r"))
157164
.AddTargets("Build")
@@ -188,7 +195,7 @@ await ObservablesForEventGenerator.ExtractEventsFromAssemblies(
188195
}
189196

190197
var eventsProject = Path.Combine(eventsDirectory, "Avalonia.ReactiveUI.Events.csproj");
191-
if (Parameters.IsRunningOnWindows)
198+
if (Parameters.IsRunningOnWindows && !IsDotnetCoreOnlyBuild())
192199
MsBuildCommon(eventsProject, c => c
193200
.SetProcessArgumentConfigurator(a => a.Add("/r"))
194201
.AddTargets("Build")
@@ -332,14 +339,15 @@ void RunCoreTest(string projectName)
332339
.After(RunTests)
333340
.Executes(() =>
334341
{
335-
if (Parameters.IsRunningOnWindows)
342+
if (Parameters.IsRunningOnWindows && !IsDotnetCoreOnlyBuild())
336343

337344
MsBuildCommon(Parameters.MSBuildSolution, c => c
338345
.AddTargets("Pack"));
339346
else
340347
DotNetPack(c => c
341348
.SetProject(Parameters.MSBuildSolution)
342349
.SetConfiguration(Parameters.Configuration)
350+
.AddProperty("PackAvaloniaNative", "true")
343351
.AddProperty("PackageVersion", Parameters.Version));
344352
});
345353

nukebuild/BuildParameters.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ public partial class Build
2222
[Parameter("skip-previewer")]
2323
public bool SkipPreviewer { get; set; }
2424

25+
[Parameter("force-dotnetcorebuild")]
26+
public bool ForceDotNetCoreBuild { get; set; }
27+
2528
public class BuildParameters
2629
{
2730
public string Configuration { get; }

0 commit comments

Comments
 (0)