Giter Site home page Giter Site logo

avalonia-dotnet-templates's People

Contributors

aarnott avatar ace4896 avatar afucher avatar angelmunoz avatar colejohnson66 avatar curia-damiano avatar emmauss avatar gridlocdev avatar grokys avatar hacklex avatar happypig375 avatar jedi-mind-tricks avatar jkoritzinsky avatar jmacato avatar jordangoulder avatar kekekeks avatar malzsmith avatar maxkatz6 avatar mrjul avatar mrxx99 avatar philippun1 avatar pjb3005 avatar pr8x avatar riqq avatar schnerring avatar simoncropp avatar takoooooo avatar thejarx avatar trinitrotoluene avatar workgroupengineering avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

avalonia-dotnet-templates's Issues

iOS build fails on Mac M1 with VS2022 using avalonia.xplat template

Describe the bug
Using a brand new project created from the Avalonia xplat template, on MacOS Monterey, it is not possible to build the iOS project.
To Reproduce
Steps to reproduce the behavior:

  1. Ensure dotnet core SDK 6.0.300 is installed
  2. Ensure the latest version of XCode is installed
  3. Create an empty directory
  4. Run dotnet new avalonia.xplat
  5. run dotnet workload restore
  6. run dotnet restore
  7. cd {myproject}.iOS
  8. dotnet run
  9. See error:
error CS0012: The type 'UIResponder' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.iOS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'.

Expected behavior
I should be able to build the iOS application and launch it on the Simulator like the Avalonia Wordle application.

Desktop (please complete the following information):

  • OS: MacOS
  • Version Monterey

Additional context
Could not isolate the difference between the Wordle application and the created application from the template. The Avalonia Wordle sample application compiles and launches, but crashes on Startup. Would appreciate a workaround until the next stable version is published if this can be solved.

Templates seem to have reference issues

I just followed the docs to set up a .Net Core App. While the template was created properly and I can even run the app, Visual Studio throws a bunch of errors:

image

I tried rebuilding, restoring nuget packages, clean+rebuild ... not sure what I'm missing here.

Consider updating to .NET 5.0?

I haven't tested it yet, but it might be a good idea to support NET 5.0 on newly created APPs since .NET 5.0 is not far from .NET 3.0 in respect of user code.

Push package to nuget.org

Please consider pushing Avalonia.Templates.NetCore package to nuget.org. It will give us an ability to use command like dotnet new --install Avalonia.Templates.NetCore to get a template without cloning the whole repo.

Consider using csproj instead of nuspec

Hello!

Consider using csproj instead of nuspec.

Since I haven't seen the days when packages were build with nuget, it seems difficult for me to use nuspec. To me easier to use dotnet pack

Example csproj:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <PackageType>Template</PackageType>
    <PackageVersion>0.1.0</PackageVersion>
    <PackageId>Avalonia.Templates</PackageId>
    <Title>Avalonia Templates</Title>
    <Authors>AvaloniaUI</Authors>

    <Description>.NET templates for Avalonia</Description>
    <PackageTags>dotnet-new dotnet-template avalonia</PackageTags>
    <PackageProjectUrl>https://github.com/AvaloniaUI/avalonia-dotnet-templates</PackageProjectUrl>
    <RepositoryUrl>https://github.com/AvaloniaUI/avalonia-dotnet-templates.git</RepositoryUrl>

    <TargetFramework>netstandard2.0</TargetFramework>
    <OutputPath>bin</OutputPath>

    <NoPackageAnalysis>true</NoPackageAnalysis>
    <NoDefaultExcludes>true</NoDefaultExcludes>

    <IncludeContentInPack>true</IncludeContentInPack>
    <IncludeBuildOutput>false</IncludeBuildOutput>
    <ContentTargetFolders>content</ContentTargetFolders>
  </PropertyGroup>

  <ItemGroup>
    <Content Include="app\**\*;app-mvvm\**\*;resource-dictionary\**\*;style\**\*;usercontrol\**\*;window\**\*;"
             Exclude="**\bin\**;**\obj\**" />
    <Compile Remove="**\*" />
  </ItemGroup>

</Project>

We can also add something like <PackageLicenseExpression>MIT</PackageLicenseExpression>

Install documentation for dotnet CLI is wrong

I'm not really sure how else to describe the issue. The blog post you link to specifically says that there needs to be a template.config\template.json file for dotnet new --install to work. However, that file doesn't exist on the repo, and pointing dotnet new --install to a clone of the repo doesn't do anything.

Ultimately I had to find the templates here, which finally gave the correct way to install them:

dotnet new --install "VitalElement.AvalonStudio.Templates"

Is it possible to update the documentation to correct this?

Remove ViewLocator or hide behind a parameter

Currently ViewLocator in the templates is an easy way to make configure multiple view + view models soltuion. But even then for proper navigation it would require a bit more research and understanding, than simple view locator can give.

On the other side, current view locator is not trimming nor AOT friendly. Making it so would make default template way too complex.

Proposal: in the default templates we should remove view locator. Main view model is already set implicitly on the main window/view by the App.xaml.cs.

linux install template issue

Hi,
is it possible to install the template on linux ?
I tried to do it but it stay like this more than 10 minutes
image

Program.cs template needs update for 0.8.1 ReactiveUI

Running a default project and upgrading to the latest 0.8.1 build produced compilation errors saying "UseReactiveUI()" wasn't a method on AppBuilder. This was do to an additional using Avalonia.ReactiveUI not being present. When 0.8.1 ships the templates should be updated.

dotnet new template generates faulty sln when hyphen is in the path

Describe the bug

dotnet new generated avalonia solutions are broken when the solution directory contains a hyphen.

To Reproduce

dotnet new avalonia.xplat -o avalonia-test
avalonia-test\avalonia-test.sln

This repros even without the -o switch if the current directory contains a hyphen.

The solution is full of bad relative paths to project files, so all the projects fail to load:
image

It becomes clear why this is when the created project files are compared to what's in the sln file:

Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "avalonia_test", "avalonia_test\avalonia_test.csproj", "{EBFA8512-1EA5-4D8C-B4AC-AB5B48A6D568}"
EndProject

Note how the hyphen in the solution directory name has been changed to the underscore character. Yet this translation did not actually happen on disk: the project directories and project filenames use a hyphen.

The generated ProjectReference items in the project files have a similar bug in using underscore instead of hyphen.

Expected behavior

The solution loads successfully in Visual Studio.
The project files use a hyphen and so do references to those projects in the sln file.

Desktop (please complete the following information):

  • OS: Windows 11
  • Version: I don't know how to look up the version of the template. But I installed it in the last couple weeks.

Mvvm Toolkit template should disable Avalonia's automatic Data Annotations validation

When using Mvvm Toolkit (CommunityToolkit.Mvvm), you get duplicate validations from both Mvvm Toolkit and Avalonia both running the validation. See AvaloniaUI/Avalonia#8397

This is a non-obvious issue with a non-obvious solution and should be included in the CommunityToolkit.Mvvm template's output by default. I still use the same solution as I mentioned in the other issue: add the following to OnFrameworkInitializationCompleted():

ExpressionObserver.DataValidators.RemoveAll(x => x is DataAnnotationsValidationPlugin);

Not run application avalonia.mvvm

Description

I get errors when trying to run an application created from the Avalonia template.

Environment
OS: Ubuntu 18.04.02
.NET Core: 2.2.202
VS Code

Steps

  1. Install avalonia-dotnet-templates
  2. Create a new project: dotnet new avalonia.mvvm
  3. sudo dotnet run --framework netcoreapp2.1

When I'm running dotnet run I get these errors:

Unhandled Exception: System.IO.FileNotFoundException: Unable to find view for ak_window.App
   at Avalonia.Markup.Xaml.AvaloniaXamlLoader.Load(Type type, Object rootInstance) in D:\a\1\s\src\Markup\Avalonia.Markup.Xaml\AvaloniaXamlLoader.cs:line 90
   at Avalonia.Markup.Xaml.AvaloniaXamlLoader.Load(Object obj) in D:\a\1\s\src\Markup\Avalonia.Markup.Xaml\AvaloniaXamlLoader.cs:line 45
   at ak_window.App.Initialize() in /home/darksait88/Документы/ak_window/App.xaml.cs:line 10
   at Avalonia.Controls.AppBuilderBase`1.Setup() in D:\a\1\s\src\Avalonia.Controls\AppBuilderBase.cs:line 302
   at Avalonia.Controls.AppBuilderBase`1.Start(AppMainDelegate main, String[] args) in D:\a\1\s\src\Avalonia.Controls\AppBuilderBase.cs:line 153
   at ak_window.Program.Main(String[] args) in /home/darksait88/Документы/ak_window/Program.cs:line 12

Avalonia.Templates v0.10.7 introduces duplicates

Hello,

I just tried with v0.10.7, I get this every time.

image

I think it's because I have F# tools installed and it ends up with duplicate names?

With v0.10.3, it works with these packages installed :

image

I'm on Windows with VS 2019 and .net5.0, but I do have VS2022 and .net6.0 preview installed.

Thanks,
Kevin

Include DataGrid theme in App.axaml for app & app-mvvm?

There may be good reasons not to do this? But would certainly have saved me some confusion

 <Application.Styles>
    <FluentTheme Mode="Light" />
    <StyleInclude Source="avares://Avalonia.Controls.DataGrid/Themes/Fluent.xaml"/>
 </Application.Styles>

Edit: Ahh perhaps because there is no package ref for Avalonia.Controls.DataGrid, it's brought in by Avalonia.Diagnostics for debug build config?

Remove InitializeComponent method from UserControl/Window in xplat template

Because we use XamlNameReferenceGenerator the InitializeComponent is generated there and causes null reference exception when accessing generated fields.

private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}

private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}

Don't add `.idea` to `.gitignore`

When creating a new project from the mvvm-template a default .gitignore is deployed that contains an ignore for .idea.

Please don't add .idea in the ignores: When Rider creates an .idea folder, it will place a .gitignore in there, which will contain the "correct" ignores for working with Rider.

error NU1108: Cycle detected.

The MVVM template is broken:

dotnet new -i Avalonia.Templates
dotnet new avalonia.mvvm
dotnet build

error NU1108: Cycle detected.
error NU1108: Avalonia -> Avalonia (>= 0.10.18).

More context:

  • Ubuntu 22.04
  • dotnet 6.0.401

VB version?

Is there a possibility for a VB implementation of this template? I have a lot of vb apps that we are wanting to convert....

Or can the templates be modified locally to use VB as the underlying language? If so, where are these templates located after the install?

Thanks In Advance

Is https://github.com/AvaloniaUI/avalonia-dotnet-templates/blob/master/templates/csharp/xplat/AvaloniaTest/AvaloniaTest.csproj intentionally targetting .NET standard 2.0 while all platform specific projects target .NET 6.0?

I have tried to use the xplat template and was kind of surprised that the main project https://github.com/AvaloniaUI/avalonia-dotnet-templates/blob/master/templates/csharp/xplat/AvaloniaTest/AvaloniaTest.csproj has <TargetFramework>netstandard2.0</TargetFramework> while all the platform specific projects like https://github.com/AvaloniaUI/avalonia-dotnet-templates/blob/master/templates/csharp/xplat/AvaloniaTest.Android/AvaloniaTest.Android.csproj use .NET 6 e.g. <TargetFramework>net6.0-android</TargetFramework> or https://github.com/AvaloniaUI/avalonia-dotnet-templates/blob/master/templates/csharp/xplat/AvaloniaTest.Desktop/AvaloniaTest.Desktop.csproj has e.g. <TargetFramework>net6.0</TargetFramework>.

As the development, after creating a new project based on the template with e.g. dotnet new avalonia.xplat, happens on the main project where I, for instance, then tried to add a NuGet package written for .NET 5, I got a message that the package is not compatible with .NET standard 2.0. I had to edit the main project's TargetFramework before being able to add and use the NuGet package.

I am wondering what the reason is for having the main project use <TargetFramework>netstandard2.0</TargetFramework> although the dedicated projects derived from it all use .NET 6. Is there any advantage to use <TargetFramework>netstandard2.0</TargetFramework>? I think that is not in any way compatible with .NET 6.

[avalonia.app] Unable to run project

Description

I get NuGet errors when I'm trying to run an app created from Avalonia template.

Environment

  • OS: Ubuntu 18.10
  • .NET Core: 2.2.202

Steps

  • Install .Net Core 2.2 SDK
  • Install avalonia-dotnet-templates
  • Create a new project: dotnet new avalonia.app -o avapp
  • Try to run the app: dotnet run

When I'm running dotnet run I get these errors:

Unable to run your project
Your project targets multiple frameworks. Please specify which framework to run using '--framework'.

Templates should create a solution, not just a csproj

This is just some feedback, but the templates should follow the norm of creating a csproj and a sln like Microsoft's official templates do, instead of the user needing to create an empty solution with Visual Studio, Visual Studio for Mac or Xamarin, then creating a project with your template, and then add the created csproj to the empty solution created earlier again using Visual Studio, Visual Studio for Mac or Xamarin. Minor nag, I know, but I feel like it's just better practice. Additionally, for Visual Studio for Mac and Xamarin, adding a project to a solution isn't very intuitive, so it leads other developers to also follow poor practices.

Windows on Arm / DevKit 2023 can't install Avalonia.Templates

Describe the bug
dotnet new install Avalonia.Templates fails on Windows on Arm / Voltera / Windows DevKit 2023

To Reproduce
on Windows 11 on Arm machine: open console, enter above command, observe error message

Expected behavior
on Windows 11 Intel x86_64 machine this is successful

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Windows Arm 64
  • Version 22623.875

Additional context
same failure during dotnet restore on Avalonia packages used in existing source code package that builds fine on other systems. (Also, arm64 Avalonia apps like Lunacy only shows black window on this machine)

"Your project targets multiple frameworks. Please specify which framework to run using '--framework'.

When using version 0.8.0 of Avalonia, the command "dotnet run" returns the error message written in the issue title. This is happening on Ubuntu with .Net Core 2.2.300 installed.

This is strange because, as far as I can tell, the only framework being targetted is netcoreapp2.1.

On a possibly-related note, these templates still use netcoreapp2.1, even though the latest is netcoreapp2.2. They should probably be updated.

Xplat web publish: initial memory too small

Hi, I'm trying to dotnet publish an Avalonia xplat web project, but get an error in the 'Linking with emcc' step: 'wasm-ld : error : initial memory too small, 23789552 bytes needed'. I see it on Mac and Windows.

To reproduce:

$ dotnet new avalonia.xplat
$ cd avaloniatest.Web 
$ dotnet publish -c Release 

Result:

....
  [87/87] Avalonia.Base.dll.bc -> Avalonia.Base.dll.o [took 306,710s]
  Linking with emcc. This may take a while ...
   "/usr/local/share/dotnet/x64/packs/Microsoft.NET.Runtime.Emscripten.2.0.23.Sdk.osx-x64/6.0.4/tools/bin/wasm-ld" @/var/folders/rp/my1ll3l50yv_5tq707x3q4f00000gn/T/emscripten_vw689brm.rsp
wasm-ld : error : initial memory too small, 23789552 bytes needed 

BTW I'm using AvaloniaVersion: 11.0.0-preview1, workload wasm-tools is installed . Is there a way to get publish working with xplat web project?

Raspberry installation hangs in loop

Hi,
I have problems with installing Avalonia on raspberry.

Preconditions:

  • I have installed dotnet 2.2*
  • dotnet new console (is working)

Now i want to add new templates for dotnet with steps

  • clone repository to raspberry
  • dotnet new --install .\avalonia-dotnet-templates\

After pressing install program hangs in loop. What i'm doing wrong?

Thanks

Using templates fails on .NET 6

Using the templates fails on .NET 6 (preview).

Workaround

Add a global.json to the folder and fix the .NET version to something other that 6.

How to reproduce

> dotnet --version
6.0.100-preview.7.21379.14

> dotnet new -i Avalonia.Templates
The following template packages will be installed:
   Avalonia.Templates

Avalonia.Templates is already installed, version: 0.10.7, it will be replaced with version .
Avalonia.Templates::0.10.7 was successfully uninstalled.
Success: Avalonia.Templates::0.10.7 installed the following templates:
Template Name                 Short Name                 Language  Tags
----------------------------  -------------------------  --------  ---------------------------
Avalonia .NET Core App        avalonia.app               F#        ui/xaml/avalonia/avaloniaui
Avalonia .NET Core App        avalonia.app               [C#]      ui/xaml/avalonia/avaloniaui
Avalonia .NET Core MVVM App   avalonia.mvvm              F#        ui/xaml/avalonia/avaloniaui
Avalonia .NET Core MVVM App   avalonia.mvvm              [C#]      ui/xaml/avalonia/avaloniaui
Avalonia Resource Dictionary  avalonia.resource                    ui/xaml/avalonia/avaloniaui
Avalonia Styles               avalonia.styles                      ui/xaml/avalonia/avaloniaui
Avalonia TemplatedControl     avalonia.templatedcontrol  [C#]      ui/xaml/avalonia/avaloniaui
Avalonia UserControl          avalonia.usercontrol       F#        ui/xaml/avalonia/avaloniaui
Avalonia UserControl          avalonia.usercontrol       [C#]      ui/xaml/avalonia/avaloniaui
Avalonia Window               avalonia.window            F#        ui/xaml/avalonia/avaloniaui
Avalonia Window               avalonia.window            [C#]      ui/xaml/avalonia/avaloniaui

> dotnet new avalonia.app
Unable to resolve the template, these templates matched your input:
Template Name                                 Short Name                 Language    Tags
--------------------------------------------  -------------------------  ----------  ---------------------------
... buch of asp.core ....
Avalonia .NET Core App                        avalonia.app               F#          ui/xaml/avalonia/avaloniaui
Avalonia .NET Core App                        avalonia.app               [C#]        ui/xaml/avalonia/avaloniaui
Avalonia .NET Core MVVM App                   avalonia.mvvm              F#          ui/xaml/avalonia/avaloniaui
Avalonia .NET Core MVVM App                   avalonia.mvvm              [C#]        ui/xaml/avalonia/avaloniaui
Avalonia Resource Dictionary                  avalonia.resource                      ui/xaml/avalonia/avaloniaui
Avalonia Styles                               avalonia.styles                        ui/xaml/avalonia/avaloniaui
Avalonia TemplatedControl                     avalonia.templatedcontrol  [C#]        ui/xaml/avalonia/avaloniaui
Avalonia UserControl                          avalonia.usercontrol       F#          ui/xaml/avalonia/avaloniaui
Avalonia UserControl                          avalonia.usercontrol       [C#]        ui/xaml/avalonia/avaloniaui
Avalonia Window                               avalonia.window            F#          ui/xaml/avalonia/avaloniaui
Avalonia Window                               avalonia.window            [C#]        ui/xaml/avalonia/avaloniaui
... virually everything else ...

Update the MVVM Template to contain one Binding

Oh, wow. I already read about RaiseAndSetIfChanged but it was not visible in my scope. So I thought it was some old technique because the example here looks way more complicated:
https://www.reactiveui.net/docs/handbook/data-binding/avalonia

I did not expect it to be just an extension method. This is why I hate extension methods 😑
Maybe the visual studio template should include such basic binding as an example.
There current example only has a one way binding.

Originally posted by @ckorn in AvaloniaUI/Avalonia#8116 (comment)

(11.0 only) Enabled compiled bindings by default

<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>

In the csproj.
Should there be a template parameter?
If so, when parameter is enabled, we can inject AvaloniaUseCompiledBindingsByDefault, otherwise inject TrimmableRootAssembly from #167

Update for dotnet 3.0

This needs to be updated to work with dotnet 3.0 I do not know whether it is avalonia proper that needs to be updated or this template or both

dotnet new avalonia.mvvm template could not build

using System;
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.ReactiveUI;

namespace dotnet
{
    class Program
    {
        // Initialization code. Don't use any Avalonia, third-party APIs or any
        // SynchronizationContext-reliant code before AppMain is called: things aren't initialized
        // yet and stuff might break.
        public static void Main(string[] args) => BuildAvaloniaApp()
            .StartWithClassicDesktopLifetime(args);

        // Avalonia configuration, don't remove; also used by visual designer.
        public static AppBuilder BuildAvaloniaApp()
            => AppBuilder.Configure<App>()
                .UsePlatformDetect()
                .LogToDebug()
                .UseReactiveUI();
    }
}

The template code generated by "dotnet new avalonia.mvvm" is missing using Avalonia.Logging.Serilog; at Program.cs, which makes LogToDebug() fails to build.

.Net core cli bug

Print
dotnet new avalonia.usercontrol -p:n Control -n Scene

Have

namespace AvaloniaAppTemplate.Namespace
{
    public partial class Scene : UserControl
    {

Incorrect namescpace

To Reproduce
Steps to reproduce the behavior:

<PackageReference Include="Avalonia" Version="0.10.18"/>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.