This commit is contained in:
Rui Marinho 2021-05-26 19:14:15 +01:00
Родитель 70e6b657ae
Коммит a6cdd372b1
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 87D2837A9AEED71E
17 изменённых файлов: 445 добавлений и 285 удалений

Просмотреть файл

@ -77,46 +77,12 @@ stages:
inputs:
versionSpec: 5.9.1
- task: DotNetCoreCLI@2
displayName: 'Install NET6'
inputs:
command: 'build'
projects: src\external\DotNet\DotNet.csproj
- script: dotnet tool restore
displayName: install dotnet tools
- task: NuGetCommand@2
displayName: 'Restore sln'
inputs:
command: 'restore'
restoreSolution: build\Build.Microsoft.Maui.Graphics.Windows.sln
- script: dotnet cake --configuration=Release
displayName: pack nugets
- task: MSBuild@1
displayName: 'Build Graphics with MSBUILD'
inputs:
solution: build\Build.Microsoft.Maui.Graphics.Windows.sln
configuration: ${{ BuildCondition }}
msbuildArguments: /verbosity:normal /t:Build
- script: src\bin\dotnet\dotnet build build\Build.Microsoft.Maui.Graphics-net6.sln -p:Configuration=${{ BuildCondition }}
displayName: 'Build Graphics with NET6'
- task: NuGetCommand@2
displayName: 'Pack nupkg'
inputs:
command: 'pack'
packagesToPack: 'build/Microsoft.Maui.Graphics.nuspec'
packDestination: '$(Build.ArtifactStagingDirectory)/${{ BuildCondition }}'
configuration: ${{ BuildCondition }}
basePath: '$(System.DefaultWorkingDirectory)'
versioningScheme : 'byEnvVar'
versionEnvVar: 'BUILD_BUILDNUMBER'
- task: MSBuild@1
displayName: 'Pack Win2D.WinUI'
inputs:
solution: src\Microsoft.Maui.Graphics.Win2D.WinUI.Desktop\Microsoft.Maui.Graphics.Win2D.WinUI.Desktop-net6.csproj
configuration: ${{ BuildCondition }}
msbuildArguments: /verbosity:normal /t:Pack -p:PackageOutputPath=$(Build.ArtifactStagingDirectory)/${{ BuildCondition }}
- task: CopyFiles@2
displayName: 'Copy SignList.xml Files'

61
build.cake Normal file
Просмотреть файл

@ -0,0 +1,61 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// examples
/*
Windows CMD:
build.cmd -Target dotnet-pack
build.cmd -Target dotnet-pack -ScriptArgs '--packageVersion="9.9.9-custom"','--configuration="Release"'
PowerShell:
./build.ps1 -Target dotnet-pack
./build.ps1 -Target dotnet-pack -ScriptArgs '--packageVersion="9.9.9-custom"'
*/
//////////////////////////////////////////////////////////////////////
// ADDINS
//////////////////////////////////////////////////////////////////////
// #addin "nuget:?package=Cake.Android.SdkManager&version=3.0.2"
// #addin "nuget:?package=Cake.Boots&version=1.0.4.600-preview1"
// #addin "nuget:?package=Cake.AppleSimulator&version=0.2.0"
// #addin "nuget:?package=Cake.FileHelpers&version=3.2.1"
#load "eng/cake/dotnet.cake"
//////////////////////////////////////////////////////////////////////
// TOOLS
//////////////////////////////////////////////////////////////////////
#tool nuget:?package=NUnit.ConsoleRunner&version=3.11.1
#tool "nuget:?package=nuget.commandline&version=5.8.1"
//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////
string agentName = EnvironmentVariable("AGENT_NAME", "");
bool isCIBuild = !String.IsNullOrWhiteSpace(agentName);
string artifactStagingDirectory = EnvironmentVariable("BUILD_ARTIFACTSTAGINGDIRECTORY", ".");
string workingDirectory = EnvironmentVariable("SYSTEM_DEFAULTWORKINGDIRECTORY", ".");
string envProgramFiles = EnvironmentVariable("ProgramFiles(x86)");
var configuration = GetBuildVariable("BUILD_CONFIGURATION", GetBuildVariable("configuration", "DEBUG"));
var msbuildPath = GetBuildVariable("msbuild", $"{envProgramFiles}\\Microsoft Visual Studio\\2019\\Enterprise\\MSBuild\\Current\\Bin\\MSBuild.exe");
bool isHostedAgent = agentName.StartsWith("Azure Pipelines") || agentName.StartsWith("Hosted Agent");
var target = Argument("target", "Default");
if(String.IsNullOrWhiteSpace(target))
target = "Default";
//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////
Task("Default").IsDependentOn("dotnet-pack");
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
RunTarget(target);

Просмотреть файл

@ -0,0 +1,3 @@
<Project>
<Import Project="../../../eng/Versions.props" />
</Project>

Просмотреть файл

@ -0,0 +1,20 @@
<Project Sdk="Microsoft.Build.NoTargets">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageDownload Include="Microsoft.Android.Ref" Version="[$(MicrosoftAndroidSdkWindowsPackageVersion)]" />
<PackageDownload Include="Microsoft.Android.Sdk.Windows" Version="[$(MicrosoftAndroidSdkWindowsPackageVersion)]" Condition="$([MSBuild]::IsOSPlatform('windows'))" />
<PackageDownload Include="Microsoft.Android.Sdk.Darwin" Version="[$(MicrosoftAndroidSdkWindowsPackageVersion)]" Condition="$([MSBuild]::IsOSPlatform('osx'))" />
<PackageDownload Include="Microsoft.Android.Sdk.BundleTool" Version="[$(MicrosoftAndroidSdkWindowsPackageVersion)]" />
<PackageDownload Include="Microsoft.MacCatalyst.Ref" Version="[$(MicrosoftMacCatalystSdkPackageVersion)]" />
<PackageDownload Include="Microsoft.MacCatalyst.Sdk" Version="[$(MicrosoftMacCatalystSdkPackageVersion)]" />
<PackageDownload Include="Microsoft.iOS.Ref" Version="[$(MicrosoftiOSSdkPackageVersion)]" />
<PackageDownload Include="Microsoft.iOS.Sdk" Version="[$(MicrosoftiOSSdkPackageVersion)]" />
<PackageDownload Include="Microsoft.iOS.Windows.Sdk" Version="[$(MicrosoftiOSSdkPackageVersion)]" Condition="$([MSBuild]::IsOSPlatform('windows'))" />
<PackageDownload Include="Microsoft.tvOS.Ref" Version="[$(MicrosofttvOSSdkPackageVersion)]" />
<PackageDownload Include="Microsoft.tvOS.Sdk" Version="[$(MicrosofttvOSSdkPackageVersion)]" />
<PackageDownload Include="Microsoft.macOS.Ref" Version="[$(MicrosoftmacOSSdkPackageVersion)]" />
<PackageDownload Include="Microsoft.macOS.Sdk" Version="[$(MicrosoftmacOSSdkPackageVersion)]" />
</ItemGroup>
</Project>

Просмотреть файл

@ -0,0 +1,12 @@
<Project Sdk="Microsoft.Build.NoTargets">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageDownload Include="Microsoft.NET.Sdk.Android.Manifest-$(DotNetPreviewVersionBand)" Version="[$(MicrosoftAndroidSdkWindowsPackageVersion)]" />
<PackageDownload Include="Microsoft.NET.Sdk.MacCatalyst.Manifest-$(DotNetPreviewVersionBand)" Version="[$(MicrosoftMacCatalystSdkPackageVersion)]" />
<PackageDownload Include="Microsoft.NET.Sdk.iOS.Manifest-$(DotNetPreviewVersionBand)" Version="[$(MicrosoftiOSSdkPackageVersion)]" />
<PackageDownload Include="Microsoft.NET.Sdk.tvOS.Manifest-$(DotNetPreviewVersionBand)" Version="[$(MicrosofttvOSSdkPackageVersion)]" />
<PackageDownload Include="Microsoft.NET.Sdk.macOS.Manifest-$(DotNetPreviewVersionBand)" Version="[$(MicrosoftmacOSSdkPackageVersion)]" />
</ItemGroup>
</Project>

174
build/DotNet/DotNet.csproj Normal file
Просмотреть файл

@ -0,0 +1,174 @@
<Project Sdk="Microsoft.Build.NoTargets">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('windows'))">
<DotNetInstallScriptUrl>https://dot.net/v1/dotnet-install.ps1</DotNetInstallScriptUrl>
<DotNetInstallScriptName>dotnet-install.ps1</DotNetInstallScriptName>
<DotNetInstallScriptPath>$(DotNetOutputPath)$(DotNetInstallScriptName)</DotNetInstallScriptPath>
<DotNetInstallCommand>&amp; '$(DotNetInstallScriptPath)' -Version $(MicrosoftDotnetSdkInternalPackageVersion) -InstallDir '$(DotNetDirectory)' -Verbose</DotNetInstallCommand>
<DotNetInstallCommand>powershell -Command &quot;$(DotNetInstallCommand)&quot;</DotNetInstallCommand>
</PropertyGroup>
<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('osx'))">
<DotNetInstallScriptUrl>https://dot.net/v1/dotnet-install.sh</DotNetInstallScriptUrl>
<DotNetInstallScriptName>dotnet-install.sh</DotNetInstallScriptName>
<DotNetInstallScriptPath>$(DotNetOutputPath)$(DotNetInstallScriptName)</DotNetInstallScriptPath>
<DotNetInstallCommand>sh '$(DotNetInstallScriptPath)' --version $(MicrosoftDotnetSdkInternalPackageVersion) --install-dir '$(DotNetDirectory)' --verbose</DotNetInstallCommand>
</PropertyGroup>
<PropertyGroup>
<_ProvisionDependsOn>
_DownloadDotNetInstallScript;
_InstallDotNet;
_AcquireWorkloads;
_AcquirePacks;
</_ProvisionDependsOn>
</PropertyGroup>
<Target Name="_Provision" BeforeTargets="Build" DependsOnTargets="$(_ProvisionDependsOn)" />
<PropertyGroup>
<!-- These files should invalidate ./bin/dotnet completely -->
<_Inputs>
$(MSBuildThisFile);
../../eng/Versions.props;
</_Inputs>
</PropertyGroup>
<Target Name="_DownloadDotNetInstallScript"
Inputs="$(_Inputs)"
Outputs="$(DotNetInstallScriptPath)">
<DownloadFile
SourceUrl="$(DotNetInstallScriptUrl)"
DestinationFolder="$(DotNetOutputPath)"
DestinationFileName="$(DotNetInstallScriptName)"
/>
</Target>
<Target Name="_InstallDotNet"
Inputs="$(_Inputs)"
Outputs="$(DotNetDirectory).stamp">
<RemoveDir Directories="$(DotNetDirectory)" />
<Exec Command="$(DotNetInstallCommand)" />
<Touch Files="$(DotNetDirectory).stamp" AlwaysCreate="true" />
</Target>
<ItemGroup>
<!-- These are past workload names -->
<_PacksToRemove Include="Microsoft.NET.Workload.Android" />
<_PacksToRemove Include="Microsoft.NET.Workload.MacCatalyst" />
<_PacksToRemove Include="Microsoft.NET.Workload.iOS" />
<_PacksToRemove Include="Microsoft.NET.Workload.tvOS" />
<_PacksToRemove Include="Microsoft.NET.Workload.macOS" />
</ItemGroup>
<Target Name="_AcquireWorkloads"
Inputs="$(_Inputs);Dependencies/Workloads.csproj"
Outputs="$(DotNetSdkManifestsDirectory).stamp">
<RemoveDir Directories="@(_PacksToRemove->'$(DotNetSdkManifestsDirectory)%(Identity)')" />
<Exec
Command="&quot;$(DotNetToolPath)&quot; restore &quot;$(MSBuildThisFileDirectory)Dependencies/Workloads.csproj&quot; -bl:$(PackageOutputPath)/DotNetWorkloads.binlog"
EnvironmentVariables="NUGET_PACKAGES=$(DotNetTempDirectory);DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1"
/>
<!--
NOTE: Workloads need to go in dotnet/sdk-manifests/6.0.100/Microsoft.NET.*/
Workloads only contain two files: data/WorkloadManifest.targets & data/WorkloadManifest.json
We downloaded these to $(DotNetTempDirectory), so we could move files individually.
-->
<ItemGroup>
<_WorkloadFiles Include="$(DotNetTempDirectory)Microsoft.NET.*/*/data/WorkloadManifest.*" />
</ItemGroup>
<CopyWorkloadFiles
Files="@(_WorkloadFiles)"
WorkloadDirectory="$(DotNetSdkManifestsDirectory)"
VersionBand="$(DotNetPreviewVersionBand)"
/>
<!-- In order to support older MSBuild versions, change the version string to an integer -->
<ReplaceText
Input="$(DotNetSdkManifestsDirectory)microsoft.net.sdk.android/WorkloadManifest.json"
OldValue="&quot;version&quot;: &quot;$(MicrosoftAndroidSdkWindowsPackageVersion)&quot;"
NewValue="&quot;version&quot;: 6"
/>
<ReplaceText
Input="$(DotNetSdkManifestsDirectory)microsoft.net.sdk.maccatalyst/WorkloadManifest.json"
OldValue="&quot;version&quot;: &quot;$(MicrosoftMacCatalystSdkPackageVersion)&quot;"
NewValue="&quot;version&quot;: 6"
/>
<ReplaceText
Input="$(DotNetSdkManifestsDirectory)microsoft.net.sdk.ios/WorkloadManifest.json"
OldValue="&quot;version&quot;: &quot;$(MicrosoftiOSSdkPackageVersion)&quot;"
NewValue="&quot;version&quot;: 6"
/>
<ReplaceText
Input="$(DotNetSdkManifestsDirectory)microsoft.net.sdk.tvos/WorkloadManifest.json"
OldValue="&quot;version&quot;: &quot;$(MicrosofttvOSSdkPackageVersion)&quot;"
NewValue="&quot;version&quot;: 6"
/>
<ReplaceText
Input="$(DotNetSdkManifestsDirectory)microsoft.net.sdk.macos/WorkloadManifest.json"
OldValue="&quot;version&quot;: &quot;$(MicrosoftmacOSSdkPackageVersion)&quot;"
NewValue="&quot;version&quot;: 6"
/>
<Touch Files="$(DotNetSdkManifestsDirectory).stamp" AlwaysCreate="true" />
</Target>
<Target Name="_AcquirePacks"
Inputs="$(_Inputs);Dependencies/Packs.csproj"
Outputs="$(DotNetPacksDirectory).stamp">
<Exec
Command="&quot;$(DotNetToolPath)&quot; restore &quot;$(MSBuildThisFileDirectory)Dependencies/Packs.csproj&quot; -bl:$(PackageOutputPath)/DotNetPacks.binlog"
EnvironmentVariables="NUGET_PACKAGES=$(DotNetPacksDirectory);DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1"
/>
<RemoveDir Directories="@(_PacksToRemove->'$(DotNetPacksDirectory)%(Identity)')" />
<Touch Files="$(DotNetPacksDirectory).stamp" AlwaysCreate="true" />
</Target>
<UsingTask TaskName="CopyWorkloadFiles"
TaskFactory="RoslynCodeTaskFactory"
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<Files ParameterType="System.String[]" Required="true" />
<WorkloadDirectory ParameterType="System.String" Required="true" />
<VersionBand ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Using Namespace="System.IO" />
<Code Type="Fragment" Language="cs">
<![CDATA[
// This is only in C#, because the equivalent MSBuild XML would not be pretty.
foreach (var file in Files)
{
var name = Directory.GetParent (file).Parent.Parent.Name;
var directory = Path.Combine(WorkloadDirectory, name.Replace($".manifest-{VersionBand}", ""));
Directory.CreateDirectory(directory);
var destination = Path.Combine(directory, Path.GetFileName(file));
Log.LogMessage($"Copying {file} to {destination}");
File.Copy(file, destination, overwrite: true);
}
]]>
</Code>
</Task>
</UsingTask>
<UsingTask TaskName="ReplaceText"
TaskFactory="RoslynCodeTaskFactory"
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<Input ParameterType="System.String" Required="true" />
<OldValue ParameterType="System.String" Required="true" />
<NewValue ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Using Namespace="System.IO" />
<Using Namespace="System.Text.RegularExpressions" />
<Code Type="Fragment" Language="cs">
<![CDATA[
var regex = new Regex(Regex.Escape(OldValue));
File.WriteAllText(Input, regex.Replace(File.ReadAllText(Input), NewValue, count: 1));
]]>
</Code>
</Task>
</UsingTask>
</Project>

28
eng/Version.Details.xml Normal file
Просмотреть файл

@ -0,0 +1,28 @@
<Dependencies>
<ProductDependencies>
<Dependency Name="Microsoft.Dotnet.Sdk.Internal" Version="6.0.100-preview.5.21260.2" CoherentParentDependency="Microsoft.Android.Sdk.Windows">
<Uri>https://github.com/dotnet/installer</Uri>
<Sha>c1feef4a98dfc1bd2913b876e620d2ed2a01b90b</Sha>
</Dependency>
<Dependency Name="Microsoft.Android.Sdk.Windows" Version="30.0.100-ci.main.2">
<Uri>https://github.com/xamarin/xamarin-android</Uri>
<Sha>92efdccb686454be32d742b8ca9f6a166a7c1808</Sha>
</Dependency>
<Dependency Name="Microsoft.MacCatalyst.Sdk" Version="14.5.100-ci.main.873">
<Uri>https://github.com/xamarin/xamarin-macios</Uri>
<Sha>592d6fefb0089528383e38e50c7545b1e0f5a971</Sha>
</Dependency>
<Dependency Name="Microsoft.iOS.Sdk" Version="14.5.100-ci.main.873">
<Uri>https://github.com/xamarin/xamarin-macios</Uri>
<Sha>592d6fefb0089528383e38e50c7545b1e0f5a971</Sha>
</Dependency>
<Dependency Name="Microsoft.tvOS.Sdk" Version="14.5.100-ci.main.873">
<Uri>https://github.com/xamarin/xamarin-macios</Uri>
<Sha>592d6fefb0089528383e38e50c7545b1e0f5a971</Sha>
</Dependency>
<Dependency Name="Microsoft.macOS.Sdk" Version="11.3.100-ci.main.873">
<Uri>https://github.com/xamarin/xamarin-macios</Uri>
<Sha>592d6fefb0089528383e38e50c7545b1e0f5a971</Sha>
</Dependency>
</ProductDependencies>
</Dependencies>

Просмотреть файл

@ -1,9 +0,0 @@
<Project>
<!--Package versions-->
<PropertyGroup>
<MicrosoftNETSdkPackageVersion>6.0.100-preview.2.21155.3</MicrosoftNETSdkPackageVersion>
<MicrosoftAndroidSdkPackageVersion>11.0.200-ci.main.148</MicrosoftAndroidSdkPackageVersion>
<MicrosoftMacCatalystSdkPackageVersion>14.3.100-ci.main.337</MicrosoftMacCatalystSdkPackageVersion>
<MicrosoftiOSSdkPackageVersion>14.4.100-ci.main.1192</MicrosoftiOSSdkPackageVersion>
</PropertyGroup>
</Project>

15
eng/Versions.props Normal file
Просмотреть файл

@ -0,0 +1,15 @@
<Project>
<!--Package versions-->
<PropertyGroup>
<MicrosoftDotnetSdkInternalPackageVersion>6.0.100-preview.5.21260.2</MicrosoftDotnetSdkInternalPackageVersion>
<MicrosoftAndroidSdkWindowsPackageVersion>30.0.100-ci.main.2</MicrosoftAndroidSdkWindowsPackageVersion>
<MicrosoftMacCatalystSdkPackageVersion>14.5.100-ci.main.873</MicrosoftMacCatalystSdkPackageVersion>
<MicrosoftiOSSdkPackageVersion>14.5.100-ci.main.873</MicrosoftiOSSdkPackageVersion>
<MicrosofttvOSSdkPackageVersion>14.5.100-ci.main.873</MicrosofttvOSSdkPackageVersion>
<MicrosoftmacOSSdkPackageVersion>11.3.100-ci.main.873</MicrosoftmacOSSdkPackageVersion>
</PropertyGroup>
<PropertyGroup>
<!-- Trim all characters after first `-` or `+` is encountered. -->
<DotNetPreviewVersionBand Condition=" '$(DotNetPreviewVersionBand)' == '' ">$([System.Text.RegularExpressions.Regex]::Replace($(MicrosoftDotnetSdkInternalPackageVersion), `[-+].*$`, ""))</DotNetPreviewVersionBand>
</PropertyGroup>
</Project>

33
eng/cake/dotnet.cake Normal file
Просмотреть файл

@ -0,0 +1,33 @@
// Contains .NET 6-related Cake targets
var ext = IsRunningOnWindows() ? ".exe" : "";
var dotnetPath = $"./bin/dotnet/dotnet{ext}";
Task("dotnet")
.Description("Provisions .NET 6 into bin/dotnet based on eng/Versions.props")
.Does(() =>
{
var binlog = $"artifacts/dotnet-{configuration}.binlog";
var settings = new DotNetCoreBuildSettings
{
MSBuildSettings = new DotNetCoreMSBuildSettings()
.EnableBinaryLogger(binlog)
.SetConfiguration(configuration),
};
DotNetCoreBuild("./build/DotNet/DotNet.csproj", settings);
});
Task("dotnet-pack")
.Description("Build and create .NET 6 NuGet packages")
.Does(()=>
{
var settings = new DotNetCoreToolSettings
{
DiagnosticOutput = true,
ArgumentCustomization = args => args.Append($"./eng/package.ps1 -configuration \"{configuration}\"")
};
DotNetCoreTool("pwsh", settings);
});

Просмотреть файл

@ -1,102 +0,0 @@
<#
.SYNOPSIS
*Windows-only* Launches Visual Studio with environment variables to use the local ./bin/dotnet/dotnet.exe.
.DESCRIPTION
*Windows-only* Launches Visual Studio with environment variables to use the local ./bin/dotnet/dotnet.exe.
Script based on:
https://github.com/dotnet/runtime/blob/1be117d8e7c0cd29ebc55cbcff2a7fa70604ed39/eng/build.ps1#L186-L208
https://github.com/dotnet/runtime/blob/1be117d8e7c0cd29ebc55cbcff2a7fa70604ed39/eng/common/tools.ps1#L109
.PARAMETER vs
The path to Visual Studio, defaults to:
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\devenv.exe".
.PARAMETER sln
The path to a .sln or .project file, defaults to "Microsoft.Maui-net6.sln".
.PARAMETER modify
Modify the environment variables in the current session. This would
allow the "dotnet" command to work instead of ".\bin\dotnet\dotnet".
However, it would be good to do this in a new terminal session,
since you would have trouble running "dotnet build" if it needs to
provision .NET 6 and the iOS/Android workloads again.
.EXAMPLE
PS> .\scripts\dogfood.ps1
.EXAMPLE
PS> .\scripts\dogfood.ps1 -vs "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\devenv.exe"
.EXAMPLE
PS> .\scripts\dogfood.ps1 -sln .\path\to\MySolution.sln
#>
param(
[string]$vs = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\devenv.exe",
[string]$sln,
[switch]$modify
)
$dotnet=Join-Path $PSScriptRoot ../bin/dotnet/
$dotnet=(Get-Item $dotnet).FullName
if (-Not $sln) {
$sln=Join-Path $PSScriptRoot ../Microsoft.Maui-net6.sln
$sln=(Get-Item $sln).FullName
}
# Modify global.json, so the IDE can load
$globaljson = Join-Path $PSScriptRoot ../global.json
[xml] $xml = Get-Content (Join-Path $PSScriptRoot Version.props)
$json = Get-Content $globaljson | ConvertFrom-Json
$json | Add-Member sdk (New-Object -TypeName PSObject) -Force
$json.sdk | Add-Member version $xml.Project.PropertyGroup.MicrosoftNETSdkPackageVersion -Force
$json | ConvertTo-Json | Set-Content $globaljson
# NOTE: I've not found a better way to do this
# see: https://github.com/PowerShell/PowerShell/issues/3316
$oldDOTNET_INSTALL_DIR=$env:DOTNET_INSTALL_DIR
$oldDOTNET_ROOT=$env:DOTNET_ROOT
$oldDOTNET_MSBUILD_SDK_RESOLVER_CLI_DIR=$env:DOTNET_MSBUILD_SDK_RESOLVER_CLI_DIR
$oldDOTNET_MULTILEVEL_LOOKUP=$env:DOTNET_MULTILEVEL_LOOKUP
$oldMSBuildEnableWorkloadResolver=$env:MSBuildEnableWorkloadResolver
$old_ExcludeMauiProjectCapability=$env:_ExcludeMauiProjectCapability
$oldPATH=$env:PATH
try {
$env:DOTNET_INSTALL_DIR=$dotnet
# This tells .NET to use the bootstrapped runtime
$env:DOTNET_ROOT=$env:DOTNET_INSTALL_DIR
# This tells MSBuild to load the SDK from the directory of the bootstrapped SDK
$env:DOTNET_MSBUILD_SDK_RESOLVER_CLI_DIR=$env:DOTNET_ROOT
# This tells .NET not to go looking for .NET in other places
$env:DOTNET_MULTILEVEL_LOOKUP=0
# This enables workload support inside the IDE
$env:MSBuildEnableWorkloadResolver=$true
# This disables the Maui @(ProjectCapability), a temporary workaround for 16.9
$env:_ExcludeMauiProjectCapability=$true
# Put our local dotnet.exe on PATH first so Visual Studio knows which one to use
$env:PATH=($env:DOTNET_ROOT + ";" + $env:PATH)
# Launch VS
& "$vs" "$sln"
} finally {
if (-Not $modify) {
$env:DOTNET_INSTALL_DIR = $oldDOTNET_INSTALL_DIR
$env:DOTNET_ROOT=$oldDOTNET_ROOT
$env:DOTNET_MSBUILD_SDK_RESOLVER_CLI_DIR=$oldDOTNET_MSBUILD_SDK_RESOLVER_CLI_DIR
$env:DOTNET_MULTILEVEL_LOOKUP=$oldDOTNET_MULTILEVEL_LOOKUP
$env:MSBuildEnableWorkloadResolver=$oldMSBuildEnableWorkloadResolver
$env:_ExcludeMauiProjectCapability=$old_ExcludeMauiProjectCapability
$env:PATH=$oldPATH
}
}
exit 0

95
eng/package.ps1 Normal file
Просмотреть файл

@ -0,0 +1,95 @@
param(
[string] $configuration = 'Debug',
[string] $msbuild = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\MSBuild.exe"
)
$ErrorActionPreference = "Stop"
Write-Host $msbuild
$artifacts = Join-Path $PSScriptRoot ../artifacts
$sln = Join-Path $PSScriptRoot ../build/Build.Microsoft.Maui.Graphics-net6.sln
# Bootstrap ./bin/dotnet/
$csproj = Join-Path $PSScriptRoot ../build/DotNet/DotNet.csproj
& dotnet build $csproj -bl:$artifacts/dotnet-$configuration.binlog
# Full path to dotnet folder
$dotnet = Join-Path $PSScriptRoot ../bin/dotnet/
$dotnet = (Get-Item $dotnet).FullName
if ($IsWindows)
{
# Modify global.json, so the IDE can load
$globaljson = Join-Path $PSScriptRoot ../global.json
[xml] $xml = Get-Content (Join-Path $PSScriptRoot Versions.props)
$json = Get-Content $globaljson | ConvertFrom-Json
$json | Add-Member sdk (New-Object -TypeName PSObject) -Force
$json.sdk | Add-Member version $xml.Project.PropertyGroup.MicrosoftDotnetSdkInternalPackageVersion -Force
$json | ConvertTo-Json | Set-Content $globaljson
# NOTE: I've not found a better way to do this
# see: https://github.com/PowerShell/PowerShell/issues/3316
$oldDOTNET_INSTALL_DIR=$env:DOTNET_INSTALL_DIR
$oldDOTNET_ROOT=$env:DOTNET_ROOT
$oldDOTNET_MSBUILD_SDK_RESOLVER_CLI_DIR=$env:DOTNET_MSBUILD_SDK_RESOLVER_CLI_DIR
$oldDOTNET_MULTILEVEL_LOOKUP=$env:DOTNET_MULTILEVEL_LOOKUP
$oldMSBuildEnableWorkloadResolver=$env:MSBuildEnableWorkloadResolver
$oldPATH=$env:PATH
try
{
$env:DOTNET_INSTALL_DIR=$dotnet
# This tells .NET to use the bootstrapped runtime
$env:DOTNET_ROOT=$dotnet
# This tells MSBuild to load the SDK from the directory of the bootstrapped SDK
$env:DOTNET_MSBUILD_SDK_RESOLVER_CLI_DIR=$env:DOTNET_ROOT
# This tells .NET not to go looking for .NET in other places
$env:DOTNET_MULTILEVEL_LOOKUP=0
# This enables workload support inside the IDE
$env:MSBuildEnableWorkloadResolver=$true
# Put our local dotnet.exe on PATH first so Visual Studio knows which one to use
$env:PATH=($dotnet + [IO.Path]::PathSeparator + $env:PATH)
& $msbuild $sln `
/p:configuration=$configuration `
/p:SymbolPackageFormat=snupkg `
/t:pack `
/p:Packing=true `
/bl:"$artifacts/maui-graphics-pack-$configuration.binlog"
if (!$?) { throw "Pack failed." }
}
finally
{
$env:DOTNET_INSTALL_DIR = $oldDOTNET_INSTALL_DIR
$env:DOTNET_ROOT=$oldDOTNET_ROOT
$env:DOTNET_MSBUILD_SDK_RESOLVER_CLI_DIR=$oldDOTNET_MSBUILD_SDK_RESOLVER_CLI_DIR
$env:DOTNET_MULTILEVEL_LOOKUP=$oldDOTNET_MULTILEVEL_LOOKUP
$env:MSBuildEnableWorkloadResolver=$oldMSBuildEnableWorkloadResolver
$env:PATH=$oldPATH
}
}
else
{
$oldPATH=$env:PATH
try
{
# Put our local dotnet on $PATH
$env:PATH=($dotnet + [IO.Path]::PathSeparator + $env:PATH)
$dotnet_tool = Join-Path $dotnet dotnet
# Build with ./bin/dotnet/dotnet
& $dotnet_tool pack $sln `
-c:$configuration `
-p:SymbolPackageFormat=snupkg `
-bl:$artifacts/maui-graphics-pack-$configuration.binlog
if (!$?) { throw "Pack failed." }
}
finally
{
$env:PATH=$oldPATH
}
}

Просмотреть файл

@ -1,3 +0,0 @@
<Project>
<Import Project="../../../../eng/Version.props" />
</Project>

15
src/external/DotNet/Dependencies/Packs.csproj поставляемый
Просмотреть файл

@ -1,15 +0,0 @@
<Project Sdk="Microsoft.Build.NoTargets">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageDownload Include="Microsoft.Android.Ref" Version="[$(MicrosoftAndroidSdkPackageVersion)]" />
<PackageDownload Include="Microsoft.Android.Sdk.win-x64" Version="[$(MicrosoftAndroidSdkPackageVersion)]" Condition="$([MSBuild]::IsOSPlatform('windows'))" />
<PackageDownload Include="Microsoft.Android.Sdk.osx-x64" Version="[$(MicrosoftAndroidSdkPackageVersion)]" Condition="$([MSBuild]::IsOSPlatform('osx'))" />
<PackageDownload Include="Microsoft.Android.Sdk.BundleTool" Version="[$(MicrosoftAndroidSdkPackageVersion)]" />
<PackageDownload Include="Microsoft.MacCatalyst.Ref" Version="[$(MicrosoftMacCatalystSdkPackageVersion)]" />
<PackageDownload Include="Microsoft.MacCatalyst.Sdk" Version="[$(MicrosoftMacCatalystSdkPackageVersion)]" />
<PackageDownload Include="Microsoft.iOS.Ref" Version="[$(MicrosoftiOSSdkPackageVersion)]" />
<PackageDownload Include="Microsoft.iOS.Sdk" Version="[$(MicrosoftiOSSdkPackageVersion)]" />
</ItemGroup>
</Project>

Просмотреть файл

@ -1,10 +0,0 @@
<Project Sdk="Microsoft.Build.NoTargets">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageDownload Include="Microsoft.NET.Workload.Android" Version="[$(MicrosoftAndroidSdkPackageVersion)]" />
<PackageDownload Include="Microsoft.NET.Workload.MacCatalyst" Version="[$(MicrosoftMacCatalystSdkPackageVersion)]" />
<PackageDownload Include="Microsoft.NET.Workload.iOS" Version="[$(MicrosoftiOSSdkPackageVersion)]" />
</ItemGroup>
</Project>

108
src/external/DotNet/DotNet.csproj поставляемый
Просмотреть файл

@ -1,108 +0,0 @@
<Project Sdk="Microsoft.Build.NoTargets">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<IsPackable>false</IsPackable>
<MauiOutputPath>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)../../bin/'))</MauiOutputPath>
<DotNetDirectory>$(MauiOutputPath)dotnet/</DotNetDirectory>
<DotNetToolPath>$(DotNetDirectory)dotnet</DotNetToolPath>
<DotNetPacksDirectory>$(DotNetDirectory)packs/</DotNetPacksDirectory>
<DotNetSdkManifestsDirectory>$(DotNetDirectory)sdk-manifests/$(MicrosoftNETSdkPackageVersion.Split('-')[0])/</DotNetSdkManifestsDirectory>
<DotNetSentinelPath>$(DotNetDirectory)sdk/$(MicrosoftNETSdkPackageVersion)/EnableWorkloadResolver.sentinel</DotNetSentinelPath>
</PropertyGroup>
<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('windows'))">
<DotNetInstallScriptUrl>https://dot.net/v1/dotnet-install.ps1</DotNetInstallScriptUrl>
<DotNetInstallScriptName>dotnet-install.ps1</DotNetInstallScriptName>
<DotNetInstallScriptPath>$(MauiOutputPath)$(DotNetInstallScriptName)</DotNetInstallScriptPath>
<DotNetInstallCommand>&amp; '$(DotNetInstallScriptPath)' -Version $(MicrosoftNETSdkPackageVersion) -InstallDir '$(DotNetDirectory)' -Verbose</DotNetInstallCommand>
<DotNetInstallCommand>powershell -Command &quot;$(DotNetInstallCommand)&quot;</DotNetInstallCommand>
</PropertyGroup>
<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('osx'))">
<DotNetInstallScriptUrl>https://dot.net/v1/dotnet-install.sh</DotNetInstallScriptUrl>
<DotNetInstallScriptName>dotnet-install.sh</DotNetInstallScriptName>
<DotNetInstallScriptPath>$(MauiOutputPath)$(DotNetInstallScriptName)</DotNetInstallScriptPath>
<DotNetInstallCommand>sh '$(DotNetInstallScriptPath)' --version $(MicrosoftNETSdkPackageVersion) --install-dir '$(DotNetDirectory)' --verbose</DotNetInstallCommand>
</PropertyGroup>
<PropertyGroup>
<_ProvisionDependsOn>
_DownloadDotNetInstallScript;
_InstallDotNet;
_AcquireWorkloads;
_AcquirePacks;
_CreateWorkloadSentinel;
</_ProvisionDependsOn>
</PropertyGroup>
<Target Name="_Provision" BeforeTargets="Build" DependsOnTargets="$(_ProvisionDependsOn)" />
<PropertyGroup>
<!-- These files should invalidate ./bin/dotnet completely -->
<_Inputs>
$(MSBuildThisFile);
../../eng/Version.props;
</_Inputs>
</PropertyGroup>
<Target Name="_DownloadDotNetInstallScript"
Inputs="$(_Inputs)"
Outputs="$(DotNetInstallScriptPath)">
<DownloadFile
SourceUrl="$(DotNetInstallScriptUrl)"
DestinationFolder="$(MauiOutputPath)"
DestinationFileName="$(DotNetInstallScriptName)"
/>
</Target>
<Target Name="_InstallDotNet"
Inputs="$(_Inputs)"
Outputs="$(DotNetDirectory).stamp">
<RemoveDir Directories="$(DotNetDirectory)" />
<Exec Command="$(DotNetInstallCommand)" />
<Touch Files="$(DotNetDirectory).stamp" AlwaysCreate="true" />
</Target>
<ItemGroup>
<!-- These are extra packs that get extracted that should be deleted -->
<_PacksToRemove Include="microsoft.build.notargets" />
<_PacksToRemove Include="microsoft.netcore.platforms" />
<_PacksToRemove Include="netstandard.library" />
</ItemGroup>
<Target Name="_AcquireWorkloads"
Inputs="$(_Inputs);Dependencies/Workloads.csproj"
Outputs="$(DotNetSdkManifestsDirectory).stamp">
<Exec
Command="&quot;$(DotNetToolPath)&quot; restore &quot;$(MSBuildThisFileDirectory)Dependencies/Workloads.csproj&quot; -bl:$(PackageOutputPath)/DotNetWorkloads.binlog"
EnvironmentVariables="NUGET_PACKAGES=$(DotNetSdkManifestsDirectory);DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1"
/>
<!--
NOTE: Workloads need to go in dotnet/sdk-manifests/6.0.100/Microsoft.Workload.NET.*/
Workloads only contain two files: WorkloadManifest.targets & WorkloadManifest.json
We have to move everything up one directory, for things to land in the right location.
-->
<ItemGroup>
<_WorkloadFiles Include="$(DotNetSdkManifestsDirectory)Microsoft.NET.Workload.*/*/WorkloadManifest.*" />
<_WorkloadDirectoriesToDelete Include="@(_WorkloadFiles->'%(RootDir)%(Directory)'->Distinct())" />
</ItemGroup>
<Copy SourceFiles="@(_WorkloadFiles)" DestinationFiles="@(_WorkloadFiles->'%(RootDir)%(Directory)../%(FileName)%(Extension)')" />
<RemoveDir Directories="@(_WorkloadDirectoriesToDelete);@(_PacksToRemove->'$(DotNetSdkManifestsDirectory)%(Identity)')" />
<Touch Files="$(DotNetSdkManifestsDirectory).stamp" AlwaysCreate="true" />
</Target>
<Target Name="_AcquirePacks"
Inputs="$(_Inputs);Dependencies/Packs.csproj"
Outputs="$(DotNetPacksDirectory).stamp">
<Exec
Command="&quot;$(DotNetToolPath)&quot; restore &quot;$(MSBuildThisFileDirectory)Dependencies/Packs.csproj&quot; -bl:$(PackageOutputPath)/DotNetPacks.binlog"
EnvironmentVariables="NUGET_PACKAGES=$(DotNetPacksDirectory);DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1"
/>
<RemoveDir Directories="@(_PacksToRemove->'$(DotNetPacksDirectory)%(Identity)')" />
<Touch Files="$(DotNetPacksDirectory).stamp" AlwaysCreate="true" />
</Target>
<Target Name="_CreateWorkloadSentinel"
Inputs="$(_Inputs)"
Outputs="$(DotNetSentinelPath)">
<Touch Files="$(DotNetSentinelPath)" AlwaysCreate="true" />
</Target>
</Project>