Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build-tools/automation/azure-pipelines-apidocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ extends:
inputs:
forceReinstallCredentialProvider: true

- script: dotnet tool update -v:n boots --version 1.1.0.36 --add-source "https://api.nuget.org/v3/index.json" --global
- script: dotnet tool update -v:n boots --version 1.1.0.36 --global
displayName: Install boots

- script: boots https://download.mono-project.com/archive/6.12.0/macos-10-universal/MonoFramework-MDK-6.12.0.188.macos10.xamarin.universal.pkg
Expand Down
2 changes: 1 addition & 1 deletion build-tools/automation/azure-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ extends:
- template: /build-tools/automation/yaml-templates/run-dotnet-preview.yaml@self
parameters:
command: new
arguments: maui -o $(Build.StagingDirectory)/MauiTestProj
arguments: maui -o $(Build.StagingDirectory)/MauiTestProj --no-restore
xaSourcePath: $(Build.SourcesDirectory)/android
displayName: Create MAUI template
continueOnError: false
Expand Down
6 changes: 4 additions & 2 deletions build-tools/automation/yaml-templates/build-windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,15 @@ stages:
displayName: Test dotnet-local.cmd - create template
inputs:
filename: dotnet-local.cmd
arguments: new android -o $(Build.StagingDirectory)/LocalWorkloadTest
arguments: new android -o "$(Build.StagingDirectory)\LocalWorkloadTest"

- task: BatchScript@1
displayName: Test dotnet-local.cmd - build template
inputs:
filename: dotnet-local.cmd
arguments: build -v:n $(Build.StagingDirectory)/LocalWorkloadTest
arguments: >-
build -v:n "$(Build.StagingDirectory)\LocalWorkloadTest"
-p:RestoreConfigFile="$(System.DefaultWorkingDirectory)\NuGet.config"

# Pack .nupkgs and extract workload packs to dotnet preview test directory
- template: /build-tools/automation/yaml-templates/run-dotnet-preview.yaml
Expand Down
8 changes: 8 additions & 0 deletions build-tools/automation/yaml-templates/variables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,11 @@ variables:
value: true
- name: DOTNET_GENERATE_ASPNET_CERTIFICATE
value: false
# Fix network isolation requirements
# See https://devdiv.visualstudio.com/DevDiv/_git/Xamarin.yaml-templates/pullrequest/750402
- name: DOTNET_CLI_WORKLOAD_UPDATE_NOTIFY_DISABLE
value: 'true'
- name: DOTNET_SDK_VULNERABILITY_CHECK_DISABLE
value: 'true'
- name: NuGetAudit
value: 'false'
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://json.schemastore.org/dotnetcli.host",
"symbolInfo": {
"skipRestore": {
"longName": "no-restore",
"shortName": ""
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
"datatype": "string",
"replaces": "SUPPORTED_OS_PLATFORM_VERSION",
"defaultValue": "24"
},
"skipRestore": {
"type": "parameter",
"datatype": "bool",
"description": "If specified, skips the automatic restore of the project on create.",
"defaultValue": "false"
}
},
"defaultName": "AndroidBinding1"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://json.schemastore.org/dotnetcli.host",
"symbolInfo": {
"skipRestore": {
"longName": "no-restore",
"shortName": ""
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
"datatype": "string",
"replaces": "SUPPORTED_OS_PLATFORM_VERSION",
"defaultValue": "24"
},
"skipRestore": {
"type": "parameter",
"datatype": "bool",
"description": "If specified, skips the automatic restore of the project on create.",
"defaultValue": "false"
}
},
"defaultName": "AndroidApp1"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://json.schemastore.org/dotnetcli.host",
"symbolInfo": {
"skipRestore": {
"longName": "no-restore",
"shortName": ""
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
"datatype": "string",
"replaces": "SUPPORTED_OS_PLATFORM_VERSION",
"defaultValue": "24"
},
"skipRestore": {
"type": "parameter",
"datatype": "bool",
"description": "If specified, skips the automatic restore of the project on create.",
"defaultValue": "false"
}
},
"defaultName": "AndroidApp1"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://json.schemastore.org/dotnetcli.host",
"symbolInfo": {
"skipRestore": {
"longName": "no-restore",
"shortName": ""
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
"datatype": "string",
"replaces": "SUPPORTED_OS_PLATFORM_VERSION",
"defaultValue": "24"
},
"skipRestore": {
"type": "parameter",
"datatype": "bool",
"description": "If specified, skips the automatic restore of the project on create.",
"defaultValue": "false"
}
},
"defaultName": "AndroidLib1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ public void DotNetBuild (string runtimeIdentifiers, bool isRelease, bool aot, bo
ProjectName = "Test Me",
RootNamespace = "Test.Me",
EnableDefaultItems = true,
ExtraNuGetConfigSources = {
// Microsoft.AspNetCore.Components.WebView is not in dotnet-public
"https://api.nuget.org/v3/index.json",
},
PackageReferences = {
new Package { Id = "Xamarin.AndroidX.AppCompat", Version = "1.3.1.1" },
// Using * here, so we explicitly get newer packages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ string PrepareProject (string testName)
CopyRecursively (CommonSampleLibraryRootDirectory, Path.Combine (tempRoot, CommonSampleLibraryName), ignore);
CopyFile (Path.Combine (XABuildPaths.TopDirectory, "Directory.Build.props"), Path.Combine (tempRoot, "Directory.Build.props" ));
var project = new XamarinAndroidApplicationProject ();
project.CopyNuGetConfig (Path.Combine (tempRoot, "NuGet.config"));
project.CopyNuGetConfig (tempRoot);
return temporaryProjectPath;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ namespace Xamarin.Android.Build.Tests
[TestFixture]
public class FilterAssembliesTests : BaseTest
{
const string DotNetPublicPackageBaseAddress = "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/flat2";

string tempDirectory;

[SetUp]
Expand All @@ -32,6 +34,20 @@ public void TearDown ()
Task<string> DownloadFromNuGet (string url, string filename = "") =>
Task.Factory.StartNew (() => new DownloadedCache ().GetAsFile (url, filename));

static string GetPackageUrl (string packageId, string version)
{
var lowercaseId = packageId.ToLowerInvariant ();
var lowercaseVersion = version.ToLowerInvariant ();
return $"{DotNetPublicPackageBaseAddress}/{lowercaseId}/{lowercaseVersion}/{lowercaseId}.{lowercaseVersion}.nupkg";
}

[Test]
public void PackageUrlIsLowercase ()
{
var actual = GetPackageUrl ("Package.ID", "1.0.0-RC1");
Assert.AreEqual ($"{DotNetPublicPackageBaseAddress}/package.id/1.0.0-rc1/package.id.1.0.0-rc1.nupkg", actual);
}

async Task<string []> GetAssembliesFromNuGet (string url, string filename, string path)
{
var assemblies = new List<string> ();
Expand Down Expand Up @@ -65,7 +81,7 @@ string [] Run (params string [] assemblies)
public async Task CircleImageView ()
{
var assemblies = await GetAssembliesFromNuGet (
"https://www.nuget.org/api/v2/package/Refractored.Controls.CircleImageView/1.0.1",
GetPackageUrl ("Refractored.Controls.CircleImageView", "1.0.1"),
"Refractored.Controls.CircleImageView.1.0.1.nupkg",
"lib/MonoAndroid10/");
var actual = Run (assemblies);
Expand All @@ -77,7 +93,7 @@ public async Task CircleImageView ()
public async Task XamarinForms ()
{
var assemblies = await GetAssembliesFromNuGet (
"https://www.nuget.org/api/v2/package/Xamarin.Forms/3.6.0.220655",
GetPackageUrl ("Xamarin.Forms", "3.6.0.220655"),
"Xamarin.Forms.3.6.0.220655.nupkg",
"lib/MonoAndroid90/");
var actual = Run (assemblies);
Expand All @@ -93,7 +109,7 @@ public async Task XamarinForms ()
public async Task GuavaListenableFuture ()
{
var assemblies = await GetAssembliesFromNuGet (
"https://www.nuget.org/api/v2/package/Xamarin.Google.Guava.ListenableFuture/1.0.0",
GetPackageUrl ("Xamarin.Google.Guava.ListenableFuture", "1.0.0"),
"Xamarin.Google.Guava.ListenableFuture.1.0.0.nupkg",
"lib/MonoAndroid50/");
var actual = Run (assemblies);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml.Linq;
using System.Reflection;
using System.Text;
using NUnit.Framework;
Expand Down Expand Up @@ -32,18 +31,43 @@ public void DotNetNew ([Values ("android", "androidlib", "android-bindinglib", "

TestOutputDirectories [TestContext.CurrentContext.Test.ID] = templatePath;
var dotnet = new DotNetCLI (Path.Combine (templatePath, $"{templateName}.csproj"));
Assert.IsTrue (dotnet.New (template), $"`dotnet new {template}` should succeed");
Assert.IsTrue (dotnet.New (template, noRestore: true), $"`dotnet new {template} --no-restore` should succeed");

var repoNuGetConfig = Path.Combine (XABuildPaths.TopDirectory, "NuGet.config");
var projectNuGetConfig = Path.Combine (dotnet.ProjectDirectory, "NuGet.config");
File.Copy (repoNuGetConfig, projectNuGetConfig);
FileAssert.AreEqual (repoNuGetConfig, projectNuGetConfig);

File.WriteAllBytes (Path.Combine (dotnet.ProjectDirectory, "foo.jar"), ResourceData.JavaSourceJarTestJar);
Assert.IsTrue (dotnet.New ("android-activity"), "`dotnet new android-activity` should succeed");
Assert.IsTrue (dotnet.New ("android-layout", Path.Combine (dotnet.ProjectDirectory, "Resources", "layout")), "`dotnet new android-layout` should succeed");

// Debug build
Assert.IsTrue (dotnet.Build (parameters: new [] { "Configuration=Debug", "TrimmerSingleWarn=false" }), "`dotnet build` should succeed");
Assert.IsTrue (dotnet.Build (parameters: GetBuildParameters ("Debug")), "`dotnet build` should succeed");
dotnet.AssertHasNoWarnings ();

// Release build
Assert.IsTrue (dotnet.Build (parameters: new [] { "Configuration=Release", "TrimmerSingleWarn=false" }), "`dotnet build` should succeed");
Assert.IsTrue (dotnet.Build (parameters: GetBuildParameters ("Release")), "`dotnet build` should succeed");
dotnet.AssertHasNoWarnings ();

string [] GetBuildParameters (string configuration)
{
var parameters = new List<string> {
$"Configuration={configuration}",
"TrimmerSingleWarn=false",
};
if (template == "androidwear") {
var mavenTargets = Path.Combine (
XABuildPaths.TopDirectory,
"src",
"Xamarin.Android.Build.Tasks",
"Tests",
"Xamarin.Android.Build.Tests",
"dotnet-public-maven.targets");
parameters.Add ($"CustomAfterMicrosoftCommonTargets=\"{mavenTargets}\"");
}
return parameters.ToArray ();
}
}

static readonly object[] DotNetPackTargetFrameworks = new object[] {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project>
<Target Name="_UseDotNetPublicMaven" BeforeTargets="_MavenRestore">
<ItemGroup>
<AndroidMavenLibrary
Update="@(AndroidMavenLibrary)"
Repository="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-maven/maven/v1"
Condition="'%(AndroidMavenLibrary.Repository)' == ''" />
</ItemGroup>
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,16 @@ protected bool Execute (params string [] args)
return succeeded;
}

public bool New (string template, string output = null)
public bool New (string template, string output = null, bool noRestore = false)
{
var arguments = new List<string> {
"new",
template,
"--output", $"\"{output ?? ProjectDirectory}\"",
};
if (noRestore) {
arguments.Add ("--no-restore");
}
return Execute (arguments.ToArray ());
}

Expand Down
3 changes: 0 additions & 3 deletions tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1668,9 +1668,6 @@ public static void logEvent(String eventName) {{

var proj = new XamarinAndroidApplicationProject {
IsRelease = isRelease,
ExtraNuGetConfigSources = {
"https://api.nuget.org/v3/index.json",
},
OtherBuildItems = {
new AndroidItem.TransformFile ("Transforms\\Metadata.xml") {
TextContent = () => $@"<metadata><attr path=""/api/package[@name='{gradleModule.PackageName}']"" name=""managedName"">Facebook</attr></metadata>",
Expand Down