xamarin / xamarin-macios

.NET for iOS, Mac Catalyst, macOS, and tvOS provide open-source bindings of the Apple SDKs for use with .NET managed languages such as C#
Other
2.46k stars 512 forks source link

[net6+] No templates for "Add File" feature in VSfM for Class Library #18887

Closed snechaev closed 1 year ago

snechaev commented 1 year ago

Related to https://github.com/xamarin/xamarin-macios/issues/15836, but specifically for the MacOS/iOS Class Library projects.

Steps to Reproduce

  1. Open Visual Studio for Mac
  2. Create a new "macOS Class Library" project.
  3. For this new project, open the context menu and choose Add - New File...

Expected Behavior

There is a designated section for macOS-related templates, containing the controllers/xibs/storyboards templates, just like for the "macOS Application" projects.

Actual Behavior

There is no such a section and no such a templates in any of the other sections. At the same time, this section exists for the "macOS Application" projects.

Environment

Version information ``` Visual Studio Professional 2022 for Mac Version 17.6.3 (build 421) Installation UUID: e1659e62-ad2c-433a-815c-fc6b80b4bd4f Runtime .NET 7.0.3 (64-bit) Architecture: X64 Microsoft.macOS.Sdk 13.1.1007; git-rev-head:8afca776a0a96613dfb7200e0917bb57f9ed5583; git-branch:release/7.0.1xx-xcode14.2 Roslyn (Language Service) 4.6.0-3.23180.6+99e956e42697a6dd886d1e12478ea2b27cceacfa NuGet Version: 6.4.0.117 .NET SDK (x64) SDK: /usr/local/share/dotnet/sdk/7.0.307/Sdks SDK Versions: 7.0.307 7.0.306 7.0.304 7.0.302 6.0.413 6.0.412 6.0.410 6.0.408 MSBuild SDKs: /Applications/Visual Studio.app/Contents/MonoBundle/MSBuild/Current/bin/Sdks .NET Runtime (x64) Runtime: /usr/local/share/dotnet/dotnet Runtime Versions: 7.0.10 7.0.9 7.0.7 7.0.5 6.0.21 6.0.20 6.0.18 6.0.16 Xamarin.Profiler Version: 1.8.0.49 Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler Updater Version: 11 Xamarin.Android Version: 13.2.1.2 (Visual Studio Professional) Commit: xamarin-android/d17-5/a8a26c7 Android SDK: /Users/sergey/Library/Developer/Xamarin/android-sdk-macosx Supported Android versions: 12.0 (API level 31) 13.0 (API level 33) SDK Command-line Tools Version: 7.0 SDK Platform Tools Version: 33.0.3 SDK Build Tools Version: 32.0.0 Build Information: Mono: d9a6e87 Java.Interop: xamarin/java.interop/d17-5@149d70fe SQLite: xamarin/sqlite/3.40.1@68c69d8 Xamarin.Android Tools: xamarin/xamarin-android-tools/d17-5@ca1552d Microsoft Build of OpenJDK Java SDK: /Library/Java/JavaVirtualMachines/microsoft-11.jdk 11.0.16.1 Android Designer EPL code available here: https://github.com/xamarin/AndroidDesigner.EPL Eclipse Temurin JDK Java SDK: /Library/Java/JavaVirtualMachines/temurin-8.jdk 1.8.0.302 Android Designer EPL code available here: https://github.com/xamarin/AndroidDesigner.EPL Android SDK Manager Version: 17.6.0.50 Hash: a715dca Branch: HEAD Build date: 2023-08-02 19:04:28 UTC Android Device Manager Version: 0.0.0.1309 Hash: 06e3e77 Branch: HEAD Build date: 2023-08-02 19:04:28 UTC Xamarin Designer Version: 17.6.3.9 Hash: 2648399ae8 Branch: remotes/origin/d17-6 Build date: 2023-08-02 19:04:23 UTC Apple Developer Tools Xcode: 14.3 21812 Build: 14E222b Xamarin.Mac Version: 9.3.0.6 Visual Studio Professional Hash: 97731c92c Branch: xcode14.3 Build date: 2023-04-11 22:38:35-0400 Xamarin.iOS Version: 16.4.0.6 Visual Studio Professional Hash: 97731c92c Branch: xcode14.3 Build date: 2023-04-11 22:38:36-0400 Build Information Release ID: 1706030421 Git revision: c90350679f1b9295edc584519320b13d06489853 Build date: 2023-08-02 19:02:50+00 Build branch: release-17.6 Build lane: release-17.6 Operating System Mac OS X 13.5.0 Darwin 22.6.0 Darwin Kernel Version 22.6.0 Wed Jul 5 22:21:56 PDT 2023 root:xnu-8796.141.3~6/RELEASE_X86_64 x86_64 ```
rolfbjarne commented 1 year ago

What does this command return when you execute it in a terminal?

dotnet new list -d
microsoft-github-policy-service[bot] commented 1 year ago

Hi @snechaev. We have added the "need-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

snechaev commented 1 year ago

The output of the dotnet new list -d is following

Global Settings Location: /Users/sergey/.templateengine
[2023-08-31 20:01:28.836] [Debug] [Template Engine] => [Execute]: Execute started
[2023-08-31 20:01:28.840] [Debug] [Microsoft.TemplateEngine.Edge.TemplateConstraintManager] => [Execute]: Found 5 constraints factories, initializing.
[2023-08-31 20:01:28.842] [Debug] [MSBuildEvaluator] => [Execute]: Output directory is: /Users/sergey.
[2023-08-31 20:01:28.842] [Debug] [MSBuildEvaluator] => [Execute]: Project full path is: <null>.
[2023-08-31 20:01:28.843] [Debug] [MSBuildEvaluator] => [Execute]: Found project files: .
[2023-08-31 20:01:28.843] [Debug] [MSBuildEvaluator] => [Execute]: No project found.
[2023-08-31 20:01:28.920] [Debug] [Microsoft.TemplateEngine.Edge.TemplateConstraintManager] => [Execute]: Waiting for 1 to be initialized initialized.
[2023-08-31 20:01:28.921] [Debug] [Microsoft.TemplateEngine.Edge.TemplateConstraintManager] => [Execute]: 1 constraints were initialized.
[2023-08-31 20:01:28.925] [Debug] [MSBuildEvaluator] => [Execute]: Configuration: '"CSharp"'
[2023-08-31 20:01:28.925] [Debug] [MSBuildEvaluator] => [Execute]: No project found. This template can only be created inside the project.
[2023-08-31 20:01:28.925] [Debug] [MSBuildEvaluator] => [Execute]: Configuration: '"VB"'
[2023-08-31 20:01:28.925] [Debug] [MSBuildEvaluator] => [Execute]: No project found. This template can only be created inside the project.
[2023-08-31 20:01:28.925] [Debug] [MSBuildEvaluator] => [Execute]: Configuration: '"CSharp"'
[2023-08-31 20:01:28.925] [Debug] [MSBuildEvaluator] => [Execute]: No project found. This template can only be created inside the project.
[2023-08-31 20:01:28.925] [Debug] [MSBuildEvaluator] => [Execute]: Configuration: '"VB"'
[2023-08-31 20:01:28.925] [Debug] [MSBuildEvaluator] => [Execute]: No project found. This template can only be created inside the project.
[2023-08-31 20:01:28.925] [Debug] [MSBuildEvaluator] => [Execute]: Configuration: '"CSharp"'
[2023-08-31 20:01:28.925] [Debug] [MSBuildEvaluator] => [Execute]: No project found. This template can only be created inside the project.
[2023-08-31 20:01:28.925] [Debug] [MSBuildEvaluator] => [Execute]: Configuration: '"VB"'
[2023-08-31 20:01:28.925] [Debug] [MSBuildEvaluator] => [Execute]: No project found. This template can only be created inside the project.
[2023-08-31 20:01:28.926] [Debug] [MSBuildEvaluator] => [Execute]: Configuration: '"VB"'
[2023-08-31 20:01:28.926] [Debug] [MSBuildEvaluator] => [Execute]: No project found. This template can only be created inside the project.
[2023-08-31 20:01:28.926] [Debug] [MSBuildEvaluator] => [Execute]: Configuration: '"CSharp"'
[2023-08-31 20:01:28.926] [Debug] [MSBuildEvaluator] => [Execute]: No project found. This template can only be created inside the project.
[2023-08-31 20:01:28.926] [Debug] [MSBuildEvaluator] => [Execute]: Configuration: '"CSharp"'
[2023-08-31 20:01:28.926] [Debug] [MSBuildEvaluator] => [Execute]: No project found. This template can only be created inside the project.
[2023-08-31 20:01:28.926] [Debug] [MSBuildEvaluator] => [Execute]: Configuration: '"VB"'
[2023-08-31 20:01:28.926] [Debug] [MSBuildEvaluator] => [Execute]: No project found. This template can only be created inside the project.
These templates matched your input: 

Template Name                                 Short Name                  Language    Tags                                                     
--------------------------------------------  --------------------------  ----------  ---------------------------------------------------------
.NET MAUI App                                 maui                        [C#]        MAUI/Android/iOS/macOS/Mac Catalyst/Windows/Tizen        
.NET MAUI Blazor App                          maui-blazor                 [C#]        MAUI/Android/iOS/macOS/Mac Catalyst/Windows/Tizen/Blazor 
.NET MAUI Class Library                       mauilib                     [C#]        MAUI/Android/iOS/macOS/Mac Catalyst/Windows/Tizen        
.NET MAUI ContentPage (C#)                    maui-page-csharp            [C#]        MAUI/Android/iOS/macOS/Mac Catalyst/WinUI/Tizen/Xaml/Code
.NET MAUI ContentPage (XAML)                  maui-page-xaml              [C#]        MAUI/Android/iOS/macOS/Mac Catalyst/WinUI/Tizen/Xaml/Code
.NET MAUI ContentView (C#)                    maui-view-csharp            [C#]        MAUI/Android/iOS/macOS/Mac Catalyst/WinUI/Tizen/Xaml/Code
.NET MAUI ContentView (XAML)                  maui-view-xaml              [C#]        MAUI/Android/iOS/macOS/Mac Catalyst/WinUI/Tizen/Xaml/Code
.NET MAUI ResourceDictionary (XAML)           maui-dict-xaml              [C#]        MAUI/Android/iOS/macOS/Mac Catalyst/WinUI/Xaml/Code      
Android Activity template                     android-activity            [C#]        Android/Mobile                                           
Android Application                           android                     [C#]        Android/Mobile                                           
Android Class Library                         androidlib                  [C#]        Android/Mobile                                           
Android Java Library Binding                  android-bindinglib          [C#]        Android/Mobile                                           
Android Layout template                       android-layout              [C#]        Android/Mobile                                           
Android Wear Application                      androidwear                 [C#]        Android/Mobile                                           
ASP.NET Core Empty                            web                         [C#],F#     Web/Empty                                                
ASP.NET Core gRPC Service                     grpc                        [C#]        Web/gRPC                                                 
ASP.NET Core Web API                          webapi                      [C#],F#     Web/WebAPI                                               
ASP.NET Core Web App                          webapp,razor                [C#]        Web/MVC/Razor Pages                                      
ASP.NET Core Web App (Model-View-Controller)  mvc                         [C#],F#     Web/MVC                                                  
ASP.NET Core with Angular                     angular                     [C#]        Web/MVC/SPA                                              
ASP.NET Core with React.js                    react                       [C#]        Web/MVC/SPA                                              
Blazor Server App                             blazorserver                [C#]        Web/Blazor                                               
Blazor Server App Empty                       blazorserver-empty          [C#]        Web/Blazor/Empty                                         
Blazor WebAssembly App                        blazorwasm                  [C#]        Web/Blazor/WebAssembly/PWA                               
Blazor WebAssembly App Empty                  blazorwasm-empty            [C#]        Web/Blazor/WebAssembly/PWA/Empty                         
Class Library                                 classlib                    [C#],F#,VB  Common/Library                                           
Console App                                   console                     [C#],F#,VB  Common/Console                                           
dotnet gitignore file                         gitignore                               Config                                                   
Dotnet local tool manifest file               tool-manifest                           Config                                                   
EditorConfig file                             editorconfig                            Config                                                   
global.json file                              globaljson                              Config                                                   
iOS Application                               ios                         [C#],F#,VB  iOS/Mobile                                               
iOS Binding Library                           iosbinding                  [C#]        iOS/Mobile                                               
iOS Class Library                             ioslib                      [C#],VB     iOS/Mobile                                               
iOS Controller                                ios-controller              [C#]        iOS/Mobile                                               
iOS Storyboard                                ios-storyboard              [C#]        iOS/Mobile                                               
iOS Tabbed Application                        ios-tabbed                  [C#]        iOS/Mobile                                               
iOS View                                      ios-view                    [C#]        iOS/Mobile                                               
iOS View Controller                           ios-viewcontroller          [C#]        iOS/Mobile                                               
Mac Catalyst Application                      maccatalyst                 [C#],VB     macOS/Mac Catalyst                                       
Mac Catalyst Binding Library                  maccatalystbinding          [C#]        macOS/Mac Catalyst                                       
Mac Catalyst Class Library                    maccatalystlib              [C#],VB     macOS/Mac Catalyst                                       
Mac Catalyst Controller                       maccatalyst-controller      [C#]        macOS/Mac Catalyst                                       
Mac Catalyst Storyboard                       maccatalyst-storyboard      [C#]        macOS/Mac Catalyst                                       
Mac Catalyst View                             maccatalyst-view            [C#]        macOS/Mac Catalyst                                       
Mac Catalyst View Controller                  maccatalyst-viewcontroller  [C#]        macOS/Mac Catalyst                                       
macOS Application                             macos                       [C#],VB     macOS                                                    
macOS Binding Library                         macosbinding                [C#]        macOS                                                    
macOS Class Library                           macoslib                    [C#],VB     macOS                                                    
macOS Controller                              macos-controller            [C#]        macOS                                                    
macOS Storyboard                              macos-storyboard            [C#]        macOS                                                    
macOS View                                    macos-view                  [C#]        macOS                                                    
macOS View Controller                         macos-viewcontroller        [C#]        macOS                                                    
MSBuild Directory.Build.props file            buildprops                              MSBuild/props                                            
MSBuild Directory.Build.targets file          buildtargets                            MSBuild/props                                            
MSTest Test Project                           mstest                      [C#],F#,VB  Test/MSTest                                              
MVC ViewImports                               viewimports                 [C#]        Web/ASP.NET                                              
MVC ViewStart                                 viewstart                   [C#]        Web/ASP.NET                                              
NuGet Config                                  nugetconfig                             Config                                                   
NUnit 3 Test Item                             nunit-test                  [C#],F#,VB  Test/NUnit                                               
NUnit 3 Test Project                          nunit                       [C#],F#,VB  Test/NUnit                                               
Protocol Buffer File                          proto                                   Web/gRPC                                                 
Razor Class Library                           razorclasslib               [C#]        Web/Razor/Library                                        
Razor Component                               razorcomponent              [C#]        Web/ASP.NET                                              
Razor Page                                    page                        [C#]        Web/ASP.NET                                              
Solution File                                 sln,solution                            Solution                                                 
tvOS Application                              tvos                        [C#],VB     tvOS/Mobile                                              
tvOS Binding Library                          tvosbinding                 [C#]        tvOS/Mobile                                              
tvOS Class Library                            tvoslib                     [C#],VB     tvOS/Mobile                                              
tvOS Controller                               tvos-controller             [C#]        tvOS/Mobile                                              
tvOS Storyboard                               tvos-storyboard             [C#]        tvOS/Mobile                                              
tvOS View                                     tvos-view                   [C#]        tvOS/Mobile                                              
tvOS View Controller                          tvos-viewcontroller         [C#]        tvOS/Mobile                                              
Web Config                                    webconfig                               Config                                                   
Worker Service                                worker                      [C#],F#     Common/Worker/Web                                        
xUnit Test Project                            xunit                       [C#],F#,VB  Test/xUnit                                               

[2023-08-31 20:01:28.946] [Debug] [Template Engine] => [Execute]: Execute finished, took 111 ms
rolfbjarne commented 1 year ago

The templates are all there:

macOS Application                             macos                       [C#],VB     macOS                                                    
macOS Binding Library                         macosbinding                [C#]        macOS                                                    
macOS Class Library                           macoslib                    [C#],VB     macOS                                                    
macOS Controller                              macos-controller            [C#]        macOS                                                    
macOS Storyboard                              macos-storyboard            [C#]        macOS                                                    
macOS View                                    macos-view                  [C#]        macOS                                                    
macOS View Controller                         macos-viewcontroller        [C#]        macOS                                                    

so I believe this is an issue in Visual Studio for Mac.

Unfortunately Visual Studio for Mac is being discontinued, so it's unlikely any time will be spent to fix this.

My suggestion would be to try VSCode and see if you get the behavior you want there, and if not, file an issue about VSCode instead.