Skip to content

Commit

Permalink
[One .NET] use **FromWorkload** for targeting/runtime pack versions (d…
Browse files Browse the repository at this point in the history
…otnet#6184)

Context: dotnet/sdk#19596

If we use the version number string of `**FromWorkload**`, then our
runtime packages don't need to be resolved from a NuGet feed. They can
be resolved from the `dotnet/packs` directory.

This completely eliminates the need for a `NuGet.config` file when
building a .NET 6 app with a local build of the Android workload.

You can simply do:

    ~/android-toolchain/dotnet/dotnet new android
    ~/android-toolchain/dotnet/dotnet build
  • Loading branch information
jonathanpeppers authored Aug 16, 2021
1 parent 4b72d31 commit 1bd24ac
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 42 deletions.
17 changes: 1 addition & 16 deletions Documentation/building/unix/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,22 +93,7 @@ but this is only part of the story. Your local
local Android "workload" in `Microsoft.Android.Sdk.$(HostOS)` matching
your operating system.

To use the Android workload, you will need a `NuGet.config`:

```xml
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="dotnet6" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json" />
<add key="local-xa" value="/full/path/to/bin/BuildDebug/nuget-unsigned" />
</packageSources>
</configuration>
```

The local package source in the `bin/BuildDebug/nuget-unsigned` directory is
currently needed for the Android runtime packages.

Then use a `.csproj` file such as:
Create a new project with `dotnet new android`:

```xml
<Project Sdk="Microsoft.NET.Sdk">
Expand Down
17 changes: 1 addition & 16 deletions Documentation/building/windows/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,22 +107,7 @@ but this is only part of the story. Your local
populated with a local Android "workload" in
`Microsoft.Android.Sdk.$(HostOS)` matching your operating system.

To use the Android workload, you will need a `NuGet.config`:

```xml
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="dotnet6" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json" />
<add key="local-xa" value="C:\full\path\to\bin\BuildDebug\nuget-unsigned" />
</packageSources>
</configuration>
```

The local package source in the `bin\BuildDebug\nuget-unsigned` directory is
currently needed for the Android runtime packages.

Then use a `.csproj` file such as:
Create a new project with `dotnet new android`:

```xml
<Project Sdk="Microsoft.NET.Sdk">
Expand Down
6 changes: 3 additions & 3 deletions build-tools/create-packs/Microsoft.Android.Sdk.proj
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and
Include="Microsoft.Android"
TargetFramework="$(_AndroidNETAppTargetFramework)"
RuntimeFrameworkName="Microsoft.Android"
DefaultRuntimeFrameworkVersion="$(AndroidPackVersionLong)"
LatestRuntimeFrameworkVersion="$(AndroidPackVersionLong)"
DefaultRuntimeFrameworkVersion="**FromWorkload**"
LatestRuntimeFrameworkVersion="**FromWorkload**"
TargetingPackName="Microsoft.Android.Ref"
TargetingPackVersion="$(AndroidPackVersionLong)"
TargetingPackVersion="**FromWorkload**"
RuntimePackNamePatterns="Microsoft.Android.Runtime.**RID**"
RuntimePackRuntimeIdentifiers="@(_AndroidNETAppRuntimePackRids, '%3B')"
Profile="Android"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public abstract class XamarinProject
public IList<BuildItem> References { get; private set; }
public IList<Package> PackageReferences { get; private set; }
public string GlobalPackagesFolder { get; set; } = FileSystemUtils.FindNugetGlobalPackageFolder ();
public IList<string> ExtraNuGetConfigSources { get; set; }
public IList<string> ExtraNuGetConfigSources { get; set; } = new List<string> ();

public virtual bool ShouldRestorePackageReferences => PackageReferences?.Count > 0;
/// <summary>
Expand Down Expand Up @@ -98,12 +98,6 @@ public XamarinProject (string debugConfigurationName = "Debug", string releaseCo
</PropertyGroup>
</Project>"
});

// Feeds only needed for .NET 5+
ExtraNuGetConfigSources = new List<string> {
Path.Combine (XABuildPaths.BuildOutputDirectory, "nuget-unsigned"),
"https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json",
};
} else {
SetProperty (KnownProperties.Configuration, () => Configuration);
}
Expand Down

0 comments on commit 1bd24ac

Please sign in to comment.