Skip to content

Commit

Permalink
Update to .NET 7 SDKs (#7375)
Browse files Browse the repository at this point in the history
Bump to:

* .NET SDK 7.0.100-preview.6.22276.1
* .NET Runtime 7.0.0-preview.5.22272.3
* Android 33.0.0-preview.4.25
* iOS/MacCatalyst/tvOS 15.4.704-ci.net7-0
* macOS 12.3.704-ci.net7-0
* Tizen 7.0.100-preview.6.7

Other changes:

* Build with `dotnet build`
* Use `net7.0` target framework
* `NET6_0` -> `NET6_0_OR_GREATER`
* Provision Android API 32
* .NET 7 workload packs need `7.0.100-preview.6` version band
* `Image*UnitTest` needs a `TaskCompletionSource` in .NET 7
* Tizen packs should check `$(IncludeTizenTargetFrameworks)`

Workarounds:

* Usage of `new NSUrlRequest(uri!)` to avoid NRT warnings
* `GetScrollYOnGenList()` on Tizen needed new linker warnings ignored
* `$(NoWarn)` is needed to workaround linker analyzers: dotnet/linker#2817
* Added additional logging for `XamlC` failing on:

    Task XamlCTask
    Error XamlApp.xaml Invalid URI: The hostname could not be parsed. 
       at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& creationOptions)
       at System.Uri..ctor(String uriString, UriKind uriKind)
       at Microsoft.Maui.Controls.ResourceDictionary.RDSourceTypeConverter.GetResourcePath(Uri uri, String rootTargetPath)
       at Microsoft.Maui.Controls.XamlC.RDSourceTypeConverter.ConvertFromString(String value, ILContext context, BaseNode node)+MoveNext()
       at Microsoft.Maui.Controls.Build.Tasks.NodeILExtensions.PushConvertedValue(ValueNode node, ILContext context, TypeReference targetTypeRef, TypeReference typeConverter, IEnumerable`1 pushServiceProvider, Boolean boxValueTypes, Boolean unboxValueTypes)+MoveNext()
       at Microsoft.Maui.Controls.Build.Tasks.SetPropertiesVisitor.Set(VariableDefinition parent, String localName, INode node, IXmlLineInfo iXmlLineInfo, ILContext context)+MoveNext()
       at Microsoft.Maui.Controls.Build.Tasks.ILProcessorExtensions.Append(ILProcessor processor, IEnumerable`1 instructions)
       at Microsoft.Maui.Controls.Build.Tasks.SetPropertiesVisitor.Visit(ValueNode node, INode parentNode)
       at Microsoft.Maui.Controls.Xaml.ElementNode.Accept(IXamlNodeVisitor visitor, INode parentNode)
       at Microsoft.Maui.Controls.Build.Tasks.SetResourcesVisitor.Visit(ElementNode node, INode parentNode)
       at Microsoft.Maui.Controls.Xaml.ElementNode.Accept(IXamlNodeVisitor visitor, INode parentNode)
       at Microsoft.Maui.Controls.Xaml.ElementNode.Accept(IXamlNodeVisitor visitor, INode parentNode)
       at Microsoft.Maui.Controls.Xaml.RootNode.Accept(IXamlNodeVisitor visitor, INode parentNode)
       at Microsoft.Maui.Controls.Build.Tasks.XamlCTask.TryCoreCompile(MethodDefinition initComp, ILRootNode rootnode, String xamlFilePath, Exception& exception)

Co-authored-by: Jonathan Peppers <[email protected]>
Co-authored-by: Jay Cho <[email protected]>
  • Loading branch information
3 people authored Jun 6, 2022
1 parent 7592c42 commit b8646cb
Show file tree
Hide file tree
Showing 141 changed files with 290 additions and 373 deletions.
18 changes: 8 additions & 10 deletions .github/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,8 @@ dotnet tool restore
dotnet cake --target=VS-NET6
```

_NOTES:_
- _If the IDE doesn't show any Android devices try unloading and reloading the `Sample.Droid-net6` project._

You can also run commands individually:

```dotnetcli
# install local tools required to build (cake, pwsh, etc..)
dotnet tool restore
Expand All @@ -142,8 +140,8 @@ To build & run .NET 6 sample apps, you will also need to use `.\bin\dotnet\dotne
installed the workloads globally: as well as need the `-f` switch to choose the platform:

```dotnetcli
.\bin\dotnet\dotnet build src\Controls\samples\Controls.Sample\Maui.Controls.Sample.csproj -t:Run -f net6.0-android
.\bin\dotnet\dotnet build src\Controls\samples\Controls.Sample\Maui.Controls.Sample.csproj -t:Run -f net6.0-ios
.\bin\dotnet\dotnet build src\Controls\samples\Controls.Sample\Maui.Controls.Sample.csproj -t:Run -f net7.0-android
.\bin\dotnet\dotnet build src\Controls\samples\Controls.Sample\Maui.Controls.Sample.csproj -t:Run -f net7.0-ios
```

#### MacOS
Expand All @@ -161,9 +159,9 @@ dotnet build Microsoft.Maui-mac.slnf
Try out a "single project", you will need the `-f` switch to choose the platform:

```bash
dotnet build src/Controls/samples/Controls.Sample/Maui.Controls.Sample.csproj -t:Run -f net6.0-ios
dotnet build src/Controls/samples/Controls.Sample/Maui.Controls.Sample.csproj -t:Run -f net6.0-maccatalyst
dotnet build src/Controls/samples/Controls.Sample/Maui.Controls.Sample.csproj -t:Run -f net6.0-android
dotnet build src/Controls/samples/Controls.Sample/Maui.Controls.Sample.csproj -t:Run -f net7.0-ios
dotnet build src/Controls/samples/Controls.Sample/Maui.Controls.Sample.csproj -t:Run -f net7.0-maccatalyst
dotnet build src/Controls/samples/Controls.Sample/Maui.Controls.Sample.csproj -t:Run -f net7.0-android
```

### Blazor Desktop
Expand Down Expand Up @@ -192,10 +190,10 @@ code in .NET MAUI:
`$(AndroidUseIntermediateDesignerFile)` to `false`.

2. Build .NET MAUI as you normally would. You will get compiler errors
about duplicate fields, but `obj\Debug\net6.0-android\Resource.designer.cs`
about duplicate fields, but `obj\Debug\net7.0-android\Resource.designer.cs`
should now be generated.

3. Open `obj\Debug\net6.0-android\Resource.designer.cs`, and find the
3. Open `obj\Debug\net7.0-android\Resource.designer.cs`, and find the
field you need such as:

```csharp
Expand Down
6 changes: 3 additions & 3 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@
// in vscode.
"id": "framework",
"type": "pickString",
"default": "net6.0-android",
"default": "net7.0-android",
"description": "Pick the framework you want to target.",
"options": [
"net6.0-android",
"net6.0-ios",
"net7.0-android",
"net7.0-ios",
]
},
{
Expand Down
7 changes: 4 additions & 3 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="eng\Versions.props" />

<PropertyGroup>
<_MauiDotNetVersion Condition="'$(_MauiDotNetVersion)' == ''">6.0</_MauiDotNetVersion>
<_MauiDotNetVersion Condition="'$(_MauiDotNetVersion)' == ''">7.0</_MauiDotNetVersion>
<_MauiDotNetTfm Condition="'$(_MauiDotNetTfm)' == ''">net$(_MauiDotNetVersion)</_MauiDotNetTfm>
<_MauiTargetPlatformIdentifier>$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)'))</_MauiTargetPlatformIdentifier>
<_MauiNoTargetPlatform Condition="'$(_MauiTargetPlatformIdentifier)' == ''">True</_MauiNoTargetPlatform>
Expand All @@ -14,7 +14,7 @@
<_MauiTargetPlatformIsWindows Condition="$(_MauiTargetPlatformIdentifier.Contains('windows')) == 'True'">True</_MauiTargetPlatformIsWindows>
<_MauiTargetPlatformIsTizen Condition="'$(_MauiTargetPlatformIdentifier)' == 'tizen'">True</_MauiTargetPlatformIsTizen>

<IncludeWindowsTargetFrameworks Condition="($([MSBuild]::IsOSPlatform('windows')) and '$(MSBuildRuntimeType)' == 'Full') or ('$(Packing)' == 'true')">true</IncludeWindowsTargetFrameworks>
<IncludeWindowsTargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows')) or '$(Packing)' == 'true'">true</IncludeWindowsTargetFrameworks>
<IncludeTizenTargetFrameworks Condition="'$(CI)' == 'true' or '$(TF_BUILD)' == 'true' or
Exists('$(DOTNET_ROOT)\sdk-manifests\$(DotNetVersionBand)\samsung.net.sdk.tizen\WorkloadManifest.json') or
Exists('$(ProgramFiles)\dotnet\sdk-manifests\$(DotNetVersionBand)\samsung.net.sdk.tizen\WorkloadManifest.json')">true</IncludeTizenTargetFrameworks>
Expand All @@ -27,6 +27,7 @@
<!-- HACK: WinUI seems to have issues without this -->
<GenerateLibraryLayout>true</GenerateLibraryLayout>
<DisableEmbeddedXbf>false</DisableEmbeddedXbf>
<EnablePreviewMsixTooling>true</EnablePreviewMsixTooling>
</PropertyGroup>

<!-- version number information -->
Expand Down Expand Up @@ -63,7 +64,7 @@
<DotNetToolPath>$(DotNetDirectory)dotnet</DotNetToolPath>
<DotNetPacksDirectory>$(DotNetDirectory)packs/</DotNetPacksDirectory>
<DotNetLibraryPacksDirectory>$(DotNetDirectory)library-packs/</DotNetLibraryPacksDirectory>
<DotNetSdkManifestsDirectory>$(DotNetDirectory)sdk-manifests/$(DotNetVersionBand)/</DotNetSdkManifestsDirectory>
<DotNetSdkManifestsDirectory>$(DotNetDirectory)sdk-manifests/$(DotNetSdkManifestsFolder)/</DotNetSdkManifestsDirectory>
<DotNetTemplatePacksDirectory>$(DotNetDirectory)template-packs/</DotNetTemplatePacksDirectory>
<_MauiBuildTasksLocation>$(_MauiBuildTasksLocation)</_MauiBuildTasksLocation>
<_MauiBuildTasksLocation Condition="'$(_MauiBuildTasksLocation)' == ''">$(MSBuildThisFileDirectory).nuspec\</_MauiBuildTasksLocation>
Expand Down
4 changes: 3 additions & 1 deletion Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
<PropertyGroup Condition="'$(_MauiTargetPlatformIsTizen)' == 'True'">
<SupportedOSPlatformVersion>6.5</SupportedOSPlatformVersion>
<TargetPlatformMinVersion>6.5</TargetPlatformMinVersion>
<!-- Workaround: https://github.com/dotnet/linker/issues/2817 -->
<NoWarn>$(NoWarn);AD0001</NoWarn>
</PropertyGroup>

<!--
Expand Down Expand Up @@ -64,7 +66,7 @@

<!-- Until we get a new enough dotnet -->
<ItemGroup Condition="'$(_MauiTargetPlatformIsWindows)' == 'True'">
<FrameworkReference Update="Microsoft.Windows.SDK.NET.Ref" RuntimeFrameworkVersion="10.0.18362.22" TargetingPackVersion="10.0.18362.22" />
<FrameworkReference Update="Microsoft.Windows.SDK.NET.Ref" RuntimeFrameworkVersion="10.0.18362.24" TargetingPackVersion="10.0.18362.24" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion GitInfo.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.0.400-preview.1
7.0.0-preview.1
32 changes: 16 additions & 16 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
<Dependencies>
<ProductDependencies>
<Dependency Name="Microsoft.Dotnet.Sdk.Internal" Version="6.0.301-rtm.22254.17" CoherentParentDependency="Microsoft.Android.Sdk.Windows">
<Dependency Name="Microsoft.Dotnet.Sdk.Internal" Version="7.0.100-preview.6.22276.1" CoherentParentDependency="Microsoft.Android.Sdk.Windows">
<Uri>https://github.com/dotnet/installer</Uri>
<Sha>3fed194c0b277b0ac0986f92401a50dd6c34f43d</Sha>
<Sha>1a6c2ec5276c14fb4bb26f94baad970bf08206b9</Sha>
</Dependency>
<Dependency Name="Microsoft.NETCore.App.Ref" Version="6.0.5" CoherentParentDependency="Microsoft.Android.Sdk.Windows">
<Dependency Name="Microsoft.NETCore.App.Ref" Version="7.0.0-preview.5.22272.3" CoherentParentDependency="Microsoft.Dotnet.Sdk.Internal">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>a21b9a2dd4c31cf5bd37626562b7612faf21cee6</Sha>
<Sha>0864cc5539e0ddd109b443b0bee804878cd7ba76</Sha>
</Dependency>
<Dependency Name="Microsoft.Android.Sdk.Windows" Version="32.0.301">
<Dependency Name="Microsoft.Android.Sdk.Windows" Version="33.0.0-preview.4.25">
<Uri>https://github.com/xamarin/xamarin-android</Uri>
<Sha>4c460a89cb070ee8dfd731842f36bc3dc68dc75c</Sha>
<Sha>f2276d43f1caa0d68dbb139157468f66e472efbf</Sha>
</Dependency>
<Dependency Name="Microsoft.MacCatalyst.Sdk" Version="15.4.303">
<Dependency Name="Microsoft.MacCatalyst.Sdk" Version="15.4.704-ci.net7-0">
<Uri>https://github.com/xamarin/xamarin-macios</Uri>
<Sha>ce10c913a2921673b0caedcd268778b46d52c392</Sha>
<Sha>99695ca947d5d9d53edf719866d5bb98211fed20</Sha>
</Dependency>
<Dependency Name="Microsoft.iOS.Sdk" Version="15.4.303">
<Dependency Name="Microsoft.iOS.Sdk" Version="15.4.704-ci.net7-0">
<Uri>https://github.com/xamarin/xamarin-macios</Uri>
<Sha>ce10c913a2921673b0caedcd268778b46d52c392</Sha>
<Sha>99695ca947d5d9d53edf719866d5bb98211fed20</Sha>
</Dependency>
<Dependency Name="Microsoft.tvOS.Sdk" Version="15.4.303">
<Dependency Name="Microsoft.tvOS.Sdk" Version="15.4.704-ci.net7-0">
<Uri>https://github.com/xamarin/xamarin-macios</Uri>
<Sha>ce10c913a2921673b0caedcd268778b46d52c392</Sha>
<Sha>99695ca947d5d9d53edf719866d5bb98211fed20</Sha>
</Dependency>
<Dependency Name="Microsoft.macOS.Sdk" Version="12.3.303">
<Dependency Name="Microsoft.macOS.Sdk" Version="12.3.704-ci.net7-0">
<Uri>https://github.com/xamarin/xamarin-macios</Uri>
<Sha>ce10c913a2921673b0caedcd268778b46d52c392</Sha>
<Sha>99695ca947d5d9d53edf719866d5bb98211fed20</Sha>
</Dependency>
<Dependency Name="Microsoft.NET.Workload.Emscripten.Manifest-6.0.300" Version="6.0.4" CoherentParentDependency="Microsoft.NETCore.App.Ref">
<Dependency Name="Microsoft.NET.Workload.Emscripten.Manifest-7.0.100" Version="7.0.0-preview.5.22252.1" CoherentParentDependency="Microsoft.NETCore.App.Ref">
<Uri>https://github.com/dotnet/emsdk</Uri>
<Sha>52e9452f82e26f9fcae791e84c082ae22f1ef66f</Sha>
<Sha>aeb9a3591b687c3f141e43b330604b34da738149</Sha>
</Dependency>
<Dependency Name="Microsoft.WindowsAppSDK" Version="0.0.1">
<Uri>https://dev.azure.com/microsoft/ProjectReunion/_git/ProjectReunionInternal</Uri>
Expand Down
35 changes: 17 additions & 18 deletions eng/Versions.props
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
<Project>
<PropertyGroup>
<!-- dotnet/installer -->
<MicrosoftDotnetSdkInternalPackageVersion>6.0.301-rtm.22254.17</MicrosoftDotnetSdkInternalPackageVersion>
<MicrosoftDotnetSdkInternalPackageVersion>7.0.100-preview.6.22276.1</MicrosoftDotnetSdkInternalPackageVersion>
<!-- dotnet/runtime -->
<MicrosoftNETCoreAppRefPackageVersion>6.0.5</MicrosoftNETCoreAppRefPackageVersion>
<MicrosoftNETCoreAppRefPackageVersion>7.0.0-preview.5.22272.3</MicrosoftNETCoreAppRefPackageVersion>
<!-- NOTE: should eventually revert back to $(MicrosoftNETCoreAppRefPackageVersion) in .NET 7 -->
<MicrosoftExtensionsPackageVersion>6.0.0</MicrosoftExtensionsPackageVersion>
<MicrosoftExtensionsServicingPackageVersion>6.0.1</MicrosoftExtensionsServicingPackageVersion>
<SystemCodeDomPackageVersion>6.0.0</SystemCodeDomPackageVersion>
<!-- xamarin/xamarin-android -->
<MicrosoftAndroidSdkWindowsPackageVersion>32.0.301</MicrosoftAndroidSdkWindowsPackageVersion>
<MicrosoftAndroidSdkWindowsPackageVersion>33.0.0-preview.4.25</MicrosoftAndroidSdkWindowsPackageVersion>
<!-- xamarin/xamarin-macios -->
<MicrosoftiOSSdkPackageVersion>15.4.303</MicrosoftiOSSdkPackageVersion>
<MicrosoftMacCatalystSdkPackageVersion>15.4.303</MicrosoftMacCatalystSdkPackageVersion>
<MicrosoftmacOSSdkPackageVersion>12.3.303</MicrosoftmacOSSdkPackageVersion>
<MicrosofttvOSSdkPackageVersion>15.4.303</MicrosofttvOSSdkPackageVersion>
<SamsungTizenSdkPackageVersion>7.0.303</SamsungTizenSdkPackageVersion>
<MicrosoftiOSSdkPackageVersion>15.4.704-ci.net7-0</MicrosoftiOSSdkPackageVersion>
<MicrosoftMacCatalystSdkPackageVersion>15.4.704-ci.net7-0</MicrosoftMacCatalystSdkPackageVersion>
<MicrosoftmacOSSdkPackageVersion>12.3.704-ci.net7-0</MicrosoftmacOSSdkPackageVersion>
<MicrosofttvOSSdkPackageVersion>15.4.704-ci.net7-0</MicrosofttvOSSdkPackageVersion>
<!-- Samsung/Tizen.NET -->
<SamsungTizenSdkPackageVersion>7.0.100-preview.6.7</SamsungTizenSdkPackageVersion>
<!-- emsdk -->
<MicrosoftNETWorkloadEmscriptenManifest60300PackageVersion>6.0.4</MicrosoftNETWorkloadEmscriptenManifest60300PackageVersion>
<MicrosoftNETWorkloadEmscriptenPackageVersion>$(MicrosoftNETWorkloadEmscriptenManifest60300PackageVersion)</MicrosoftNETWorkloadEmscriptenPackageVersion>
<MicrosoftNETWorkloadEmscriptenManifest70100PackageVersion>7.0.0-preview.5.22252.1</MicrosoftNETWorkloadEmscriptenManifest70100PackageVersion>
<MicrosoftNETWorkloadEmscriptenPackageVersion>$(MicrosoftNETWorkloadEmscriptenManifest70100PackageVersion)</MicrosoftNETWorkloadEmscriptenPackageVersion>
<!-- wasdk -->
<MicrosoftWindowsAppSDKPackageVersion>1.0.3</MicrosoftWindowsAppSDKPackageVersion>
<MicrosoftWindowsAppSDKPackageVersion>1.1.0</MicrosoftWindowsAppSDKPackageVersion>
<MicrosoftWindowsSDKBuildToolsPackageVersion>10.0.22000.194</MicrosoftWindowsSDKBuildToolsPackageVersion>
<MicrosoftGraphicsWin2DPackageVersion>1.0.3.1</MicrosoftGraphicsWin2DPackageVersion>
<!-- Everything else -->
Expand Down Expand Up @@ -62,15 +63,13 @@
<FizzlerPackageVersion>1.2.0</FizzlerPackageVersion>
</PropertyGroup>
<PropertyGroup>
<!-- Match the first three version numbers and append 00 -->
<!-- <DotNetVersionBand Condition=" '$(DotNetVersionBand)' == '' ">$([System.Text.RegularExpressions.Regex]::Match($(MicrosoftDotnetSdkInternalPackageVersion), `^\d+\.\d+\.\d`))00</DotNetVersionBand> -->
<DotNetVersionBand Condition=" '$(DotNetVersionBand)' == '' ">6.0.300</DotNetVersionBand>
<!-- NOTE: temporarily hardcode these to 6.0.200 -->
<DotNetVersionBand Condition=" '$(DotNetVersionBand)' == '' ">7.0.100</DotNetVersionBand>
<DotNetSdkManifestsFolder>$(DotNetVersionBand)$([System.Text.RegularExpressions.Regex]::Match($(MicrosoftDotnetSdkInternalPackageVersion), `\-preview.\d+`))</DotNetSdkManifestsFolder>
<DotNetMauiManifestVersionBand>$(DotNetVersionBand)</DotNetMauiManifestVersionBand>
<DotNetMonoManifestVersionBand>$(DotNetVersionBand)</DotNetMonoManifestVersionBand>
<DotNetEmscriptenManifestVersionBand>$(DotNetVersionBand)</DotNetEmscriptenManifestVersionBand>
<DotNetAndroidManifestVersionBand>$(DotNetVersionBand)</DotNetAndroidManifestVersionBand>
<DotNetMaciOSManifestVersionBand>$(DotNetVersionBand)</DotNetMaciOSManifestVersionBand>
<DotNetTizenManifestVersionBand>$(DotNetVersionBand)</DotNetTizenManifestVersionBand>
<DotNetAndroidManifestVersionBand>$(DotNetSdkManifestsFolder)</DotNetAndroidManifestVersionBand>
<DotNetMaciOSManifestVersionBand>$(DotNetSdkManifestsFolder)</DotNetMaciOSManifestVersionBand>
<DotNetTizenManifestVersionBand>$(DotNetSdkManifestsFolder)</DotNetTizenManifestVersionBand>
</PropertyGroup>
</Project>
126 changes: 34 additions & 92 deletions eng/cake/dotnet.cake
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,11 @@ Task("dotnet-templates")

// Enable Tizen
ReplaceTextInFiles($"{projectName}/*.csproj",
"<!-- <TargetFrameworks>$(TargetFrameworks);net6.0-tizen</TargetFrameworks> -->",
"<TargetFrameworks>$(TargetFrameworks);net6.0-tizen</TargetFrameworks>");
"<!-- <TargetFrameworks>",
"<TargetFrameworks>");
ReplaceTextInFiles($"{projectName}/*.csproj",
"</TargetFrameworks> -->",
"</TargetFrameworks>");

// Build
RunMSBuildWithDotNet(projectName, properties, warningsAsError: true, forceDotNetBuild: forceDotNetBuild);
Expand Down Expand Up @@ -439,29 +442,6 @@ bool RunPackTarget()
return false;
}

string FindMSBuild()
{
if (!string.IsNullOrWhiteSpace(MSBuildExe))
return MSBuildExe;

if (IsRunningOnWindows())
{
var vsInstallation = VSWhereLatest(new VSWhereLatestSettings { Requires = "Microsoft.Component.MSBuild", IncludePrerelease = true });
if (vsInstallation != null)
{
var path = vsInstallation.CombineWithFilePath(@"MSBuild\Current\Bin\MSBuild.exe");
if (FileExists(path))
return path.FullPath;

path = vsInstallation.CombineWithFilePath(@"MSBuild\15.0\Bin\MSBuild.exe");
if (FileExists(path))
return path.FullPath;
}
}
return "msbuild";
}


Dictionary<string, string> GetDotNetEnvironmentVariables()
{
Dictionary<string, string> envVariables = new Dictionary<string, string>();
Expand Down Expand Up @@ -571,83 +551,45 @@ void RunMSBuildWithDotNet(
if(localDotnet)
SetDotNetEnvironmentVariables();

// If we're not on Windows, use ./bin/dotnet/dotnet
if (useDotNetBuild)
var msbuildSettings = new DotNetCoreMSBuildSettings()
.SetConfiguration(configuration)
.SetMaxCpuCount(0)
.WithTarget(target)
.EnableBinaryLogger(binlog);

if (warningsAsError)
{
var msbuildSettings = new DotNetCoreMSBuildSettings()
.SetConfiguration(configuration)
.SetMaxCpuCount(0)
.WithTarget(target)
.EnableBinaryLogger(binlog);
msbuildSettings.TreatAllWarningsAs(MSBuildTreatAllWarningsAs.Error);
}

if (warningsAsError)
if (properties != null)
{
foreach (var property in properties)
{
msbuildSettings.TreatAllWarningsAs(MSBuildTreatAllWarningsAs.Error);
msbuildSettings.WithProperty(property.Key, property.Value);
}
}

if (properties != null)
{
foreach (var property in properties)
{
msbuildSettings.WithProperty(property.Key, property.Value);
}
}

var dotnetBuildSettings = new DotNetCoreBuildSettings
{
MSBuildSettings = msbuildSettings,
};

dotnetBuildSettings.ArgumentCustomization = args =>
{
if (!restore)
args.Append("--no-restore");

if (!string.IsNullOrEmpty(targetFramework))
args.Append($"-f {targetFramework}");

return args;
};

if (localDotnet)
dotnetBuildSettings.ToolPath = dotnetPath;
var dotnetBuildSettings = new DotNetCoreBuildSettings
{
MSBuildSettings = msbuildSettings,
};

DotNetCoreBuild(sln, dotnetBuildSettings);
}
else
dotnetBuildSettings.ArgumentCustomization = args =>
{
// Otherwise we need to run MSBuild for WinUI support
var msbuild = FindMSBuild();
Information("Using MSBuild: {0}", msbuild);
var msbuildSettings = new MSBuildSettings { ToolPath = msbuild }
.SetConfiguration(configuration)
.SetMaxCpuCount(0)
.WithTarget(target)
.EnableBinaryLogger(binlog);

if (warningsAsError)
{
msbuildSettings.WarningsAsError = true;
}
if (restore)
{
msbuildSettings.WithRestore();
}
if (!restore)
args.Append("--no-restore");

if (!string.IsNullOrEmpty(targetFramework))
{
msbuildSettings.WithProperty("TargetFramework", targetFramework);
}
args.Append($"-f {targetFramework}");

if (properties != null)
{
foreach (var property in properties)
{
msbuildSettings.WithProperty(property.Key, property.Value);
}
}
return args;
};

MSBuild(sln, msbuildSettings);
}
if (localDotnet)
dotnetBuildSettings.ToolPath = dotnetPath;

DotNetCoreBuild(sln, dotnetBuildSettings);
}

void RunTestWithLocalDotNet(string csproj)
Expand Down
2 changes: 1 addition & 1 deletion eng/devices/android.cake
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ string DEVICE_NAME = Argument("skin", EnvironmentVariable("ANDROID_TEST_SKIN") ?
// optional
var USE_DOTNET = Argument("dotnet", true);
var DOTNET_PATH = Argument("dotnet-path", EnvironmentVariable("DOTNET_PATH"));
var TARGET_FRAMEWORK = Argument("tfm", EnvironmentVariable("TARGET_FRAMEWORK") ?? (USE_DOTNET ? "net6.0-android" : ""));
var TARGET_FRAMEWORK = Argument("tfm", EnvironmentVariable("TARGET_FRAMEWORK") ?? (USE_DOTNET ? "net7.0-android" : ""));
var BINLOG_ARG = Argument("binlog", EnvironmentVariable("ANDROID_TEST_BINLOG") ?? "");
DirectoryPath BINLOG_DIR = string.IsNullOrEmpty(BINLOG_ARG) && !string.IsNullOrEmpty(PROJECT.FullPath) ? PROJECT.GetDirectory() : BINLOG_ARG;
var TEST_APP = Argument("app", EnvironmentVariable("ANDROID_TEST_APP") ?? "");
Expand Down
Loading

0 comments on commit b8646cb

Please sign in to comment.