Skip to content

Commit

Permalink
feat(vsmac): Add support for unoapp template solution filters
Browse files Browse the repository at this point in the history
This change eases the creation and loading of Uno App templates in Visual Studio for mac
  • Loading branch information
jeromelaban committed Sep 15, 2021
1 parent 823d420 commit 36146b4
Show file tree
Hide file tree
Showing 8 changed files with 148 additions and 42 deletions.
46 changes: 22 additions & 24 deletions doc/articles/get-started-vsmac.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,54 +12,52 @@ While it is easier to create apps using Uno Platform on Windows, you can also cr
* [**GTK+3**](https://formulae.brew.sh/formula/gtk+3) for running the Skia/GTK projects

## Installing the dotnet new templates
- In order to create a new Uno Project, you'll need to install the [`dotnet new` Uno Platform templates](get-started-dotnet-new.md).
- Once done, in Visual Studio for Mac, open the preference menu:
- On left side, open the **Other** then **Preview Features** menu
- Check the **Show all .NET Core templates in the New Project dialog**
In order to create a new Uno Project, you'll need to install the [`dotnet new` Uno Platform templates](get-started-dotnet-new.md).

## Create a new project using the IDE
1. To create a new project:
- Click the **New** button on the welcome screen
- Select **Cross Platform App (Uno Platform)**
- If presented with a list of options, uncheck **Skia/WPF**
- Choose a name then click create
1. To create a new project, from the command line:
```
cd src
dotnet new unoapp -o MyApp01
```
1. Once created, you should see your folder structure set up like this:
![folder-structure](Assets/quick-start/vs-mac-folder-structure.png)\
1. Once created, open the `MyApp-vsmac.slnf` file
- This `slnf` is called a solution filter, which automatically excludes projects which are not compatible with Visual Studio for mac.
- If you have a warning symbol on your iOS project, make sure you have the minimum version of Xcode installed.
![update-xcode](Assets/quick-start/xcode-version-warning.jpg)\
To update, go to `Visual Studio > Preferences > Projects > SDK Locations > Apple` and select Xcode 12 or higher.
Restart Visual Studio.
1. If you did not get presented a list of options to create the project, as of Visual Studio for Mac 8.8, the Uno Platform template contains WPF projects that prevent NuGet restore to work properly. To fix this:
- Select the `MyProject.Skia.Wpf` and `MyProject.Skia.Wpf.Host`
- Right click to remove them from the solution.
- At the top of the tree, on the solution node, right click and select **Restore Nuget Packages**
1. You can now run on iOS, Android, and macOS by setting your startup project and running.
![startup-projects](Assets/quick-start/vs-mac-build.png)
1. You can now run on iOS, Android, macOS and Skia.GTK projects by changing your startup project and start the debugger.
Note: You will not be able to build the UWP and WPF projects on a Mac. All changes to this project must be made on Windows.
## Create a new project using the command line
## Create a other projects types using the command line
You can create a new Uno Platfom solution with the following terminal command:
```bash
dotnet new unoapp -o MyProject --skia-wpf=false
dotnet new unoapp -o MyProject --wasm=false
```
Once created, you can open it using the Visual Studio IDE.
Once created, you can open it using the Visual Studio IDE.
### Build and Run for WebAssembly
Building for WebAssembly takes a few more steps:
1. Set `MyProject.Wasm` to startup project
2. Build the project
3. In the terminal, navigate to your build output. This will typically be: `MyProject.Wasm > bin > Debug > netstandard2.0 > dist > server.py` Run the `server.py` program.
4. In your browser, open localhost:8000.
1. Build the project
1. In the terminal, navigate to your build output path. This will typically be: `MyProject.Wasm > bin > Debug > net5.0 > dist`
1. Install `dotnet serve`:
```
dotnet tool install -g dotnet-serve
```
1. Once installed type `dotnet serve`.
4. Navigate to the url presented by the tool to run your application
### Video Tutorial
[![Getting Started Visual Studio Mac Video](Assets/vsmac-cover.JPG)](http://www.youtube.com/watch?v=ESGJr6kHQg0 "")
### Getting Help
If you have issues with Visual Studio and Uno Platform, please visit our [Discord](https://www.platform.uno/discord) - #uno-platform channel or [StackOverflow](https://stackoverflow.com/questions/tagged/uno-platform) where our engineering team and community will be able to help you.
If you have issues with Visual Studio and Uno Platform, please visit our [Discord](https://www.platform.uno/discord) - #uno-platform channel or [StackOverflow](https://stackoverflow.com/questions/tagged/uno-platform) where our engineering team and community will be able to help you.
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,28 @@

<ItemGroup>
<None Remove="content\unoapp-net6\NuGet.config" />
<None Remove="content\unoapp-net6\UnoQuickStart-vsmac.slnf" />
<None Remove="content\unoapp-winui-net6\UnoWinUIQuickStart-vsmac.slnf" />
<None Remove="content\unoapp-winui\UnoWinUIQuickStart-vsmac.slnf" />
</ItemGroup>

<ItemGroup>
<UpToDateCheckInput Remove="content\unoapp-net6\NuGet.config" />
<UpToDateCheckInput Remove="content\unoapp-net6\UnoQuickStart-vsmac.slnf" />
<UpToDateCheckInput Remove="content\unoapp-winui-net6\UnoWinUIQuickStart-vsmac.slnf" />
<UpToDateCheckInput Remove="content\unoapp-winui\UnoWinUIQuickStart-vsmac.slnf" />
</ItemGroup>

<ItemGroup>
<Content Update="content\unoapp-net6\UnoQuickStart-vsmac.slnf">
<PackagePath>content\unoapp</PackagePath>
</Content>
<Content Update="content\unoapp-winui-net6\UnoWinUIQuickStart-vsmac.slnf">
<PackagePath>content\unoapp</PackagePath>
</Content>
<Content Update="content\unoapp-winui\UnoWinUIQuickStart-vsmac.slnf">
<PackagePath>content\unoapp</PackagePath>
</Content>
</ItemGroup>

<Target Name="CopyUnoAppTemplate" BeforeTargets="Build">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
"Microsoft.VisualStudio.Component.VC.Tools.ARM",
"Microsoft.VisualStudio.ComponentGroup.UWP.VC",
"Microsoft.VisualStudio.Workload.Universal",
"Microsoft.VisualStudio.ComponentGroup.Maui.All",
"Component.OpenJDK",
"Microsoft.VisualStudio.Component.MonoDebugger",
"Microsoft.VisualStudio.Component.Merq",
Expand All @@ -92,6 +91,7 @@
"Component.Xamarin",
"Component.Android.SDK28",
"Microsoft.VisualStudio.Workload.NetCrossPlat",
"Microsoft.VisualStudio.Workload.NetCoreTools"
"Microsoft.VisualStudio.Workload.NetCoreTools",
"Microsoft.VisualStudio.ComponentGroup.Maui.All",
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"solution": {
"path": "UnoQuickStart.sln",
"projects": [
"UnoQuickStart.Shared\\UnoQuickStart.Shared.shproj",

#//#if (Mobile)
"UnoQuickStart.Mobile\\UnoQuickStart.Mobile.csproj",
#//#endif

#//#if (WebAssembly)
"UnoQuickStart.Wasm\\UnoQuickStart.Wasm.csproj",
#//#endif

#//#if (skia-gtk)
"UnoQuickStart.Skia.Gtk\\UnoQuickStart.Skia.Gtk.csproj",
#//#endif

#//#if (skia-linux-fb)
"UnoQuickStart.Skia.Linux.FrameBuffer\\UnoQuickStart.Skia.Linux.FrameBuffer.csproj",
#//#endif
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@
"Microsoft.NetCore.Component.Runtime.3.1",
"Microsoft.NetCore.Component.SDK",
"Microsoft.VisualStudio.Component.NuGet",
"Microsoft.Net.Component.4.6.1.TargetingPack",
"Microsoft.VisualStudio.Component.Roslyn.Compiler",
"Microsoft.VisualStudio.Component.Roslyn.LanguageServices",
"Microsoft.NetCore.Component.DevelopmentTools",
"Microsoft.VisualStudio.ComponentGroup.WebToolsExtensions",
"Microsoft.VisualStudio.Component.DockerTools",
"Microsoft.NetCore.Component.Web",
"Microsoft.Net.Component.4.8.SDK",
"Microsoft.Net.Component.4.7.2.TargetingPack",
"Microsoft.Net.ComponentGroup.DevelopmentPrerequisites",
"Microsoft.VisualStudio.Component.TypeScript.4.0",
"Microsoft.VisualStudio.Component.JavaScript.TypeScript",
Expand All @@ -30,8 +27,6 @@
"Microsoft.VisualStudio.Component.MSODBC.SQL",
"Microsoft.VisualStudio.Component.MSSQL.CMDLnUtils",
"Microsoft.VisualStudio.Component.ManagedDesktop.Core",
"Microsoft.Net.Component.4.5.2.TargetingPack",
"Microsoft.Net.Component.4.5.TargetingPack",
"Microsoft.VisualStudio.Component.SQL.SSDT",
"Microsoft.VisualStudio.Component.SQL.DataSources",
"Component.Microsoft.Web.LibraryManager",
Expand All @@ -40,9 +35,6 @@
"Microsoft.VisualStudio.Component.IntelliCode",
"Component.Microsoft.VisualStudio.LiveShare",
"Microsoft.VisualStudio.ComponentGroup.Web.Client",
"Microsoft.Net.Component.4.TargetingPack",
"Microsoft.Net.Component.4.5.1.TargetingPack",
"Microsoft.Net.Component.4.6.TargetingPack",
"Microsoft.Net.ComponentGroup.TargetingPacks.Common",
"Component.Microsoft.VisualStudio.Web.AzureFunctions",
"Microsoft.VisualStudio.ComponentGroup.AzureFunctions",
Expand All @@ -58,9 +50,6 @@
"Microsoft.VisualStudio.Component.AppInsights.Tools",
"Microsoft.VisualStudio.Component.WebDeploy",
"Microsoft.VisualStudio.Component.Wcf.Tooling",
"Microsoft.Net.Component.4.6.2.TargetingPack",
"Microsoft.Net.Component.4.7.TargetingPack",
"Microsoft.Net.Component.4.7.1.TargetingPack",
"Microsoft.VisualStudio.Workload.NetWeb",
"Microsoft.VisualStudio.ComponentGroup.Azure.Prerequisites",
"Microsoft.VisualStudio.Component.Azure.Waverton.BuildTools",
Expand Down Expand Up @@ -103,10 +92,6 @@
"Component.Android.SDK28",
"Microsoft.VisualStudio.Workload.NetCrossPlat",
"Microsoft.VisualStudio.Workload.NetCoreTools",
"Microsoft.Net.Component.4.6.1.SDK",
"Microsoft.Net.Component.4.6.2.SDK",
"Microsoft.Net.Component.4.7.SDK",
"Microsoft.Net.Component.4.7.1.SDK",
"Microsoft.Net.Component.4.7.2.SDK"
"Microsoft.VisualStudio.ComponentGroup.Maui.All",
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"solution": {
"path": "UnoWinUIQuickStart.sln",
"projects": [
"UnoWinUIQuickStart.Shared\\UnoWinUIQuickStart.Shared.shproj",

#//#if (Mobile)
"UnoWinUIQuickStart.Mobile\\UnoWinUIQuickStart.Mobile.csproj",
#//#endif

#//#if (WebAssembly)
"UnoWinUIQuickStart.Wasm\\UnoWinUIQuickStart.Wasm.csproj",
#//#endif

#//#if (skia-gtk)
"UnoWinUIQuickStart.Skia.Gtk\\UnoWinUIQuickStart.Skia.Gtk.csproj",
#//#endif
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"solution": {
"path": "UnoWinUIQuickStart.sln",
"projects": [
"UnoWinUIQuickStart.Shared\\UnoWinUIQuickStart.Shared.shproj",

#//#if (Android)
"UnoWinUIQuickStart.Droid\\UnoWinUIQuickStart.Droid.csproj",
#//#endif

#//#if (iOS)
"UnoWinUIQuickStart.iOS\\UnoWinUIQuickStart.iOS.csproj",
#//#endif

#//#if (WebAssembly)
"UnoWinUIQuickStart.Wasm\\UnoWinUIQuickStart.Wasm.csproj",
#//#endif

#//#if (macOS)
"UnoWinUIQuickStart.macOS\\UnoWinUIQuickStart.macOS.csproj",
#//#endif

#//#if (skia-gtk)
"UnoWinUIQuickStart.Skia.Gtk\\UnoWinUIQuickStart.Skia.Gtk.csproj",
#//#endif
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"solution": {
"path": "UnoQuickStart.sln",
"projects": [
"UnoQuickStart.Shared\\UnoQuickStart.Shared.shproj",

#//#if (Android)
"UnoQuickStart.Droid\\UnoQuickStart.Droid.csproj",
#//#endif

#//#if (iOS)
"UnoQuickStart.iOS\\UnoQuickStart.iOS.csproj",
#//#endif


#//#if (WebAssembly)
"UnoQuickStart.Wasm\\UnoQuickStart.Wasm.csproj",
#//#endif

#//#if (macOS)
"UnoQuickStart.macOS\\UnoQuickStart.macOS.csproj",
#//#endif

#//#if (skia-gtk)
"UnoQuickStart.Skia.Gtk\\UnoQuickStart.Skia.Gtk.csproj",
#//#endif

#//#if (skia-linux-fb)
"UnoQuickStart.Skia.Linux.FrameBuffer\\UnoQuickStart.Skia.Linux.FrameBuffer.csproj",
#//#endif
]
}
}

0 comments on commit 36146b4

Please sign in to comment.