rehansaeed.github.io icon indicating copy to clipboard operation
rehansaeed.github.io copied to clipboard

[Comment] .NET Boxed Visual Studio Integration

Open RehanSaeed opened this issue 3 years ago • 16 comments

https://rehansaeed.com/dotnet-boxed-visual-studio-integration/

RehanSaeed avatar May 27 '21 10:05 RehanSaeed

Doesn't work on VS 2019 16.10 for me. Works on 2019 16.11 Preview.

Edit: no, I tell a lie. It doesn't work for me in 16.11 either. It creates a minimal solution file and a project folder then apparently dies without creating any other project files.

mike1880 avatar May 28 '21 10:05 mike1880

@mike1880 Which project did you try?

RehanSaeed avatar May 28 '21 10:05 RehanSaeed

Asp.Net Core API Boxed. No source control, no reverse proxy, no analytics, cloud provider Azure, xml formatter XMLSerializer. I have .Net 6.0 installed which sometimes causes problems (e.g. WinUI projects) if that's any help.

mike1880 avatar May 28 '21 10:05 mike1880

Thanks @mike1880, that seems like a bug in VS so I raised https://github.com/sayedihashimi/template-sample/issues/29. Lets see what answer we get. In the mean time, you can continue to use the CLI which does work.

RehanSaeed avatar May 28 '21 11:05 RehanSaeed

@RehanSaeed i left a comment on issue https://github.com/sayedihashimi/template-sample/issues/29 ....

basically the template works from VS when we enter values to all the fields...

lohithgn avatar May 30 '21 03:05 lohithgn

Doesn't appear in the dropdown for project types at all in v16.10 (final). I tried uninstalling and reinstalling the templates (because I had previously installed them for earlier version of VS).

Btw, this might help, but I have both VS 2019 16.10 and 16.11 (preview) installed.

oising avatar Jun 01 '21 14:06 oising

It should work in 16.10+, when a blank solution is created that happens because the template has a required parameter, that has no default value, and is not provided by the user. We should update Visual Studio to block project creation at that time. @RehanSaeed I would recommend that you provide default values for all required parameters. Even after we block project creation for this case, it won't be a great experience for users, especially since the template has lots of parameters (it may be difficult for the user to find the missing parameter that needs to be filled in).

sayedihashimi avatar Jun 03 '21 20:06 sayedihashimi

This now seems to be fixed in Boxed.Templates version 6.3.3. Thanks for identifying the issue.

RehanSaeed avatar Jun 07 '21 10:06 RehanSaeed

I have the same problem as @oising, none of the templates appear in the new project dialog (16.11 preview). I tried with and without the preview flag (Show all .NET Core templates in the New Project dialog). "dotnet new" shows the templates.

m-meier avatar Jun 09 '21 07:06 m-meier

@oising @m-meier You need the latest version of the template installed for it to be displayed. Can you check that you have the latest installed by running:

dotnet new --update-check
dotnet new --update-apply

Alternatively:

dotnet new --uninstall Boxed.Templates
dotnet new --install Boxed.Templates

RehanSaeed avatar Jun 09 '21 08:06 RehanSaeed

I already had 6.3.3. I tried reinstalling (and even a system reboot), but nothing worked.

PS U:\> dotnet new --update-check
All template packages are up-to-date.
PS U:\> dotnet new --uninstall Boxed.Templates
Success: Boxed.Templates::6.3.3 was uninstalled.
PS U:\> dotnet new --install Boxed.Templates
The following template packages will be installed:
  Boxed.Templates

Success: Boxed.Templates::6.3.3 installed the following templates:
Template Name               Short Name     Language  Tags
--------------------------  -------------  --------  ----------------------------
ASP.NET Core API Boxed      api            [C#]      .NET Boxed/Cloud/Service/Web
ASP.NET Core GraphQL Boxed  graphql        [C#]      .NET Boxed/Cloud/Service/Web
ASP.NET Core Orleans Boxed  orleans        [C#]      .NET Boxed/Cloud/Service/Web
NuGet Package Boxed         nuget          [C#]      .NET Boxed/Library

m-meier avatar Jun 09 '21 08:06 m-meier

@sayedihashimi Can we expect dotnet new templates to work in VS 16.11 preview? If you have 16.11 preview installed, can we expect 16.10 to still work?

RehanSaeed avatar Jun 09 '21 08:06 RehanSaeed

I still don't get the templates appearing in 16.10, only in 16.11. I can generate a solution in 16.11 but it won't build. The projects are generated as .Net 5.0 but it looks to be referencing .Net 6.0 in build; there are around 70 or so CS8032 errors, for example: "An instance of analyzer Microsoft.CodeAnalysis.MakeFieldReadonly.MakeFieldReadonlyDiagnosticAnalyzer cannot be created from C:\Program Files\dotnet\sdk\6.0.100-preview.4.21255.9\Sdks\Microsoft.NET.Sdk\codestyle\cs\Microsoft.CodeAnalysis.CodeStyle.dll : Could not load file or assembly 'Microsoft.CodeAnalysis, Version=4.0.0.0, Culture=neutral, {app name} PublicKeyToken={value}' or one of its dependencies. The system cannot find the file specified.."

mike1880 avatar Jun 09 '21 08:06 mike1880

Thanks @mike1880.

@sayedihashimi Is there some way I can stop VS 16.11 retargeting the TFM to .Net 6.0?

RehanSaeed avatar Jun 09 '21 08:06 RehanSaeed

@RehanSaeed: Now the templates appear for me. I added a visual studio feature (IIS debugging), afterwards the templates were available. I guess the installation cleared some cache or something similar.

I got the solution running on kestrel with 16.11 by switching the build target to 6.0, disabling build time code analysis and fixing an error from a non-nullable reference type and access to ActionContext (derefence from a possible null reference).

m-meier avatar Jun 09 '21 08:06 m-meier

@RehanSaeed

@sayedihashimi Is there some way I can stop VS 16.11 retargeting the TFM to .Net 6.0?

Can you explain more what you are seeing? Are you saying that the user selected .NET 5 as the TFM and then VS used .net 6 instead?

sayedihashimi avatar Jun 15 '21 22:06 sayedihashimi