From 53c35bb470fc85da12c3fe2c15152d6bdd7f2e37 Mon Sep 17 00:00:00 2001 From: Sandy Armstrong Date: Tue, 1 Mar 2022 12:41:21 -0800 Subject: [PATCH] EditorFeatures.Cocoa: Build with net6.0-macos Use a 6.0.200 SDK and macos workload 12.1.301-preview.13.7 Builds fine on Windows. On Mac, first build fails with: /usr/local/share/dotnet/sdk/6.0.200/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(356,5): error NETSDK1073: The FrameworkReference 'Microsoft.WindowsDesktop.App.WPF' was not recognized [/Users/sandy/xam-git/roslyn/src/EditorFeatures/Core/Microsoft.CodeAnalysis.EditorFeatures.csproj] Second build succeeds. --- eng/Versions.props | 6 ++--- eng/build.ps1 | 24 +++++++++++++++++++ eng/build.sh | 1 + global.json | 13 ++++++++-- ...t.CodeAnalysis.EditorFeatures.Cocoa.csproj | 7 +++--- .../Core.Cocoa/Preview/PreviewPane.cs | 3 ++- 6 files changed, 45 insertions(+), 9 deletions(-) diff --git a/eng/Versions.props b/eng/Versions.props index db28578cd2987..441b389862a04 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -25,8 +25,7 @@ 0.1.127-beta 4.0.1 - 16.10.230 - 17.0.487 + 17.2.178-preview 5.0.0-alpha1.19409.1 5.0.0-preview.1.20112.8 17.2.3 @@ -136,6 +135,7 @@ $(VisualStudioEditorNewPackagesVersion) $(MicrosoftVisualStudioExtensibilityTestingVersion) $(MicrosoftVisualStudioExtensibilityTestingVersion) + $(VisualStudioEditorNewPackagesVersion) $(MicrosoftVisualStudioShellPackagesVersion) $(MicrosoftVisualStudioShellPackagesVersion) $(MicrosoftVisualStudioShellPackagesVersion) @@ -173,7 +173,7 @@ $(VisualStudioEditorNewPackagesVersion) $(VisualStudioEditorNewPackagesVersion) $(VisualStudioEditorNewPackagesVersion) - $(VisualStudioEditorPackagesVersion) + $(VisualStudioEditorNewPackagesVersion) 17.0.64 17.0.64 $(MicrosoftVisualStudioShellPackagesVersion) diff --git a/eng/build.ps1 b/eng/build.ps1 index f9cc3577e3ddb..e84034b902d2b 100644 --- a/eng/build.ps1 +++ b/eng/build.ps1 @@ -723,6 +723,30 @@ try { if ($restore) { &(Ensure-DotNetSdk) tool restore + + # TODO: Move this to Install-DotNetWorkload.ps1 + # TODO: Implement the same thing in bash for build.sh, even though we don't build EF.Cocoa on Unix + foreach ($workload in $GlobalJson.workloads.PSObject.Properties) { + $workloadName = $workload.Name + $shortWorkloadName = $workloadName.Substring($workloadName.LastIndexOf(".") + 1) + + $rollbackJson = @{} + $rollbackJson[$workloadName] = $workload.Value.version + + $rollbackFile = New-TemporaryFile + $rollbackJson | ConvertTo-Json | Set-Content -Path $rollbackFile + + $sourcesArgs = @() + foreach ($source in $workload.Value.sources) { + $sourcesArgs += "--source" + $sourcesArgs += $source + } + + # NOTE: This requires elevated access if using a system dotnet install + &(Ensure-DotNetSdk) workload install $shortWorkloadName --from-rollback-file $rollbackFile $sourcesArgs + + Remove-Item $rollbackFile + } } try diff --git a/eng/build.sh b/eng/build.sh index 9ec073ab72113..c643d51c7b1ec 100755 --- a/eng/build.sh +++ b/eng/build.sh @@ -295,6 +295,7 @@ fi InitializeDotNetCli $install if [[ "$restore" == true && "$source_build" != true ]]; then dotnet tool restore + dotnet workload install macos # TODO: Specify version fi bootstrap_dir="" diff --git a/global.json b/global.json index 63deb07b740d7..f9bd453f3a816 100644 --- a/global.json +++ b/global.json @@ -1,11 +1,11 @@ { "sdk": { - "version": "6.0.100", + "version": "6.0.200", "allowPrerelease": true, "rollForward": "latestPatch" }, "tools": { - "dotnet": "6.0.100", + "dotnet": "6.0.200", "vs": { "version": "16.10" }, @@ -14,5 +14,14 @@ "msbuild-sdks": { "Microsoft.DotNet.Arcade.Sdk": "7.0.0-beta.22122.3", "Microsoft.DotNet.Helix.Sdk": "7.0.0-beta.22122.3" + }, + "workloads": { + "microsoft.net.sdk.macos": { + "version": "12.1.301-preview.13.7", + "sources": [ + "https://aka.ms/dotnet6/nuget/index.json", + "https://api.nuget.org/v3/index.json" + ] + } } } diff --git a/src/EditorFeatures/Core.Cocoa/Microsoft.CodeAnalysis.EditorFeatures.Cocoa.csproj b/src/EditorFeatures/Core.Cocoa/Microsoft.CodeAnalysis.EditorFeatures.Cocoa.csproj index ef02ec45167a3..afd3666218682 100644 --- a/src/EditorFeatures/Core.Cocoa/Microsoft.CodeAnalysis.EditorFeatures.Cocoa.csproj +++ b/src/EditorFeatures/Core.Cocoa/Microsoft.CodeAnalysis.EditorFeatures.Cocoa.csproj @@ -1,7 +1,9 @@  - net472 + net6.0-macos $(DefineConstants);COCOA + + false true @@ -31,7 +33,7 @@ - + @@ -41,7 +43,6 @@ - diff --git a/src/EditorFeatures/Core.Cocoa/Preview/PreviewPane.cs b/src/EditorFeatures/Core.Cocoa/Preview/PreviewPane.cs index b395e9abea6dd..310dc50111ba5 100644 --- a/src/EditorFeatures/Core.Cocoa/Preview/PreviewPane.cs +++ b/src/EditorFeatures/Core.Cocoa/Preview/PreviewPane.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using AppKit; using Foundation; +using ObjCRuntime; using Microsoft.CodeAnalysis.Editor.Shared.Extensions; using Microsoft.VisualStudio.Text.Differencing; @@ -95,7 +96,7 @@ public PreviewPane(string? id, string? title, Uri? helpLink, string? helpLinkToo new Microsoft.VisualStudio.Text.SnapshotPoint(_differenceViewerPreview.Viewer.InlineView.TextSnapshot, 0)); } - public PreviewPane(IntPtr ptr) + public PreviewPane(NativeHandle ptr) : base(ptr) { }