Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

.NET Maui "Single Project" #13858

Merged
merged 1 commit into from
Feb 26, 2021

Conversation

jonathanpeppers
Copy link
Member

@jonathanpeppers jonathanpeppers commented Feb 24, 2021

Description of Change

Context: https://github.com/xamarin/xamarin-android/blob/fcd9c30164d4ac0e88440357b5c96b9fdebccb39/Documentation/guides/OneDotNetSingleProject.md

We are aiming to get a new project type working that would have a
.csproj such as:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net6.0-android;net6.0-ios</TargetFramework>
    <OutputType>Exe</OutputType>
    <SingleProject>true</SingleProject>
  </PropertyGroup>
</Project>

Within the project you would have:

  • *.cs all shared code
  • iOS/* - iOS only stuff, including Info.plist
  • Android/* - Android only stuff, including AndroidManifest.xml

I also used some other new settings that results in a smaller
Info.plist and AndroidManifest.xml:

<ApplicationTitle>Single Project</ApplicationTitle>
<ApplicationId>com.microsoft.maui.singleproject</ApplicationId>
<ApplicationVersion>1.0</ApplicationVersion>
<AndroidVersionCode>1</AndroidVersionCode>

The eventual goal being we might be able to completely get rid of
Info.plist and AndroidManifest.xml for simple apps. You would only
need them for edge-case, platform-specific features.

To get this working within a NuGet package, we can include two new
files:

  • Xamarin.Forms.SingleProject.props
  • Xamarin.Forms.SingleProject.targets

They only enable things conditionally, if $(SingleProject) is set.

I created a new sample with a single Label to demonstrate things
working.

API Changes

None

Platforms Affected

  • Core/MSBuild (all platforms)

Behavioral/Visual Changes

A new $(SingleProject) MSBuild property will opt you into a new, magical project type.

Before/After Screenshots

Not applicable

PR Checklist

  • Targets the correct branch
  • Tests are passing (or failures are unrelated)

@jonathanpeppers jonathanpeppers force-pushed the maui-singleproject branch 2 times, most recently from 1f5defb to 7334d29 Compare February 26, 2021 14:07
Context: https://github.com/xamarin/xamarin-android/blob/fcd9c30164d4ac0e88440357b5c96b9fdebccb39/Documentation/guides/OneDotNetSingleProject.md

We are aiming to get a new project type working that would have a
`.csproj` such as:

    <Project Sdk="Microsoft.NET.Sdk">
      <PropertyGroup>
        <TargetFramework>net6.0-android;net6.0-ios</TargetFramework>
        <OutputType>Exe</OutputType>
        <SingleProject>true</SingleProject>
      </PropertyGroup>
    </Project>

Within the project you would have:

* `*.cs` all shared code
* `iOS/*` - iOS only stuff, including `Info.plist`
* `Android/*` - Android only stuff, including `AndroidManifest.xml`

I also used some other new settings that results in a smaller
`Info.plist` and `AndroidManifest.xml`:

    <ApplicationTitle>Single Project</ApplicationTitle>
    <ApplicationId>com.microsoft.maui.singleproject</ApplicationId>
    <ApplicationVersion>1.0</ApplicationVersion>
    <AndroidVersionCode>1</AndroidVersionCode>

The eventual goal being we might be able to completely get rid of
`Info.plist` and `AndroidManifest.xml` for simple apps. You would only
need them for edge-case, platform-specific features.

To get this working within a NuGet package, we can include two new
files:

* `Xamarin.Forms.SingleProject.props`
* `Xamarin.Forms.SingleProject.targets`

They only enable things conditionally, if `$(SingleProject)` is set.

I created a new sample with a single `Label` to demonstrate things
working.
@PureWeen PureWeen merged commit 0e94f14 into xamarin:main-handler Feb 26, 2021
@jonathanpeppers jonathanpeppers deleted the maui-singleproject branch February 26, 2021 15:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants