neozhu / CleanArchitectureWithBlazorServer

This is a repository for creating a Blazor Server dashboard application following the principles of Clean Architecture
https://architecture.blazorserver.com/
MIT License
817 stars 221 forks source link

Code Generator fails #293

Closed buda56 closed 1 year ago

buda56 commented 1 year ago

CodeGen_Issue Your code generator does not work in Visual Studio, I was really looking forward to using your application but this is a big let down. Keeps throwing COM error when right clicking on project to use the generator.

Regards Peter

neozhu commented 1 year ago

uninstall the extension build it install again

buda56 commented 1 year ago

I didn't install the extension from source code, I downloaded it from the Extensions installer in Visual Studio??

So not sure what you mean by uninstall, build it, install again??

Regards Peter

buda56 commented 1 year ago

Hi, I downloaded the source code for the CodeGenerator add in and built and installed after removing the exisitng version I had.

I cleaned my solution, rebuilt and then tried again, I am getting the exact same issue.

Regards Peter

neozhu commented 1 year ago

Sorry, I don't know, you can fork my project for test (https://github.com/neozhu/CleanArchitectureWithBlazorServer), in my project it's working

Bram1903 commented 1 year ago

@neozhu, any updates on what should happen with this issue?

neozhu commented 1 year ago

@neozhu, any updates on what should happen with this issue?

I don't know, I was tested it's working, Maybe you can test it

Bram1903 commented 1 year ago

@neozhu, any updates on what should happen with this issue?

I don't know, I was tested it's working, Maybe you can test it

I'm using Rider from JetBrains, so I'm not able to test that extension, unfortunately. ;-(

buda56 commented 1 year ago

@Bram1903 @neozhu I have tried everything and cannot get it to work, I went in another direction and am using the Blazor BoilerPlate template instead. Such a pity I really liked your tool.

Bram1903 commented 1 year ago

@buda56 I'll install VS on my gaming desktop this weekend, and see if I can get it to work. Sorry to hear that it doesn't work for you! 😕

buda56 commented 1 year ago

@Bram1903 OK thanks, my setup is Microsoft Visual Studio Community 2022 (64-bit) - Current Version 17.5.5, plus 1/2 dozen add-ins. It'd be nice to get it working as it creates all the plumbing required.

neozhu commented 1 year ago

@buda56 is it working now? You can try it as following:

  1. pull new version from GitHub
  2. compile the project(build with Debug)
  3. go to src\bin\Debug\CleanArchitectureCodeGenerator.vsix and install it (before uninstall)
buda56 commented 1 year ago

@neozhu I downloaded the project but cannot build, requires Docker Desktop (never used Docker). So I installed Docker Desktop but the build still fails with the same error message..

Severity Code Description Project File Line Suppression State Error Visual Studio Container Tools requires Docker Desktop. To get it, see https://go.microsoft.com/fwlink/?linkid=847268

neozhu commented 1 year ago

The docker environment is not necessary. You can remove the docker-compose project in the solution like this: image

buda56 commented 1 year ago

@neozhu My bad, wrong project download, downloaded the correct one and I can compile okay. I have removed and re-installed the Generator. I also cloned your https://github.com/neozhu/CleanArchitectureWithBlazorServer and tried it with that and it works fine but am having trouble generating the cli template

neozhu commented 1 year ago

No problem at all! I'm glad to hear that you were able to download the correct project and successfully compile it. Regarding the CLI template issue, I understand that it can be a bit tricky to create a solution template in Visual Studio.

To create a solution template, you can follow these steps:

  1. First, make sure your project is well-structured and organized, as this will be the basis for your template.

  2. In your project folder, create a new file named ".template.config" and inside it, create another folder named "template.json". This file will contain the metadata and configuration settings for your template.

  3. Open the "template.json" file and add the necessary information, such as the template's name, description, and author. You can refer to the official documentation for more details on the required fields and their values.

  4. Once you have completed the "template.json" file, you can package your project as a .nupkg file using the dotnet pack command. This will create a NuGet package that can be installed and used as a template.

  5. To install the template, use the dotnet new --install [path-to-nupkg-file] command. After installation, your template should be available in Visual Studio and can be used to create new projects.

I hope this helps you with generating the CLI template. If you have any further questions or need assistance, please don't hesitate to ask.

Bram1903 commented 1 year ago

No problem at all! I'm glad to hear that you were able to download the correct project and successfully compile it. Regarding the CLI template issue, I understand that it can be a bit tricky to create a solution template in Visual Studio.

To create a solution template, you can follow these steps:

  1. First, make sure your project is well-structured and organized, as this will be the basis for your template.
  2. In your project folder, create a new file named ".template.config" and inside it, create another folder named "template.json". This file will contain the metadata and configuration settings for your template.
  3. Open the "template.json" file and add the necessary information, such as the template's name, description, and author. You can refer to the official documentation for more details on the required fields and their values.
  4. Once you have completed the "template.json" file, you can package your project as a .nupkg file using the dotnet pack command. This will create a NuGet package that can be installed and used as a template.
  5. To install the template, use the dotnet new --install [path-to-nupkg-file] command. After installation, your template should be available in Visual Studio and can be used to create new projects.

I hope this helps you with generating the CLI template. If you have any further questions or need assistance, please don't hesitate to ask.

@buda56 Did this answer solve your issue?

buda56 commented 1 year ago

@Bram1903 Thanks for the reply, I haven't had a chance to test this. I will update this thread once I haver had the chance to do so.

buda56 commented 1 year ago

@neozhu @Bram1903 Hi I still can't get the CLI template generated, I am trying to use the project downloaded from GitHub to produce the template but it created nupkg files in all the solutions (Application, Blazor.Server.Ui etc).

Regards Peter

neozhu commented 1 year ago

do you succeed make template for this

buda56 commented 1 year ago

@neozhu no I have not been able to

buda56 commented 1 year ago

@neozhu @Bram1903 This is getting quiet frustrating, still cannot generate the template, all works good if I clone the repository. Have added the output of CLI whilst trying to generate the template:

PS D:\Shared\Source\Repos\Test\CleanArchitectureWithBlazorServer.template.config> dotnet new --install sayedha.templates Warning: use of 'dotnet new --install' is deprecated. Use 'dotnet new install' instead. For more information, run: dotnet new install -h

The following template packages will be installed: sayedha.templates

sayedha.templates (version 1.0.6) is already installed, it will be replaced with latest version. sayedha.templates::1.0.6 was successfully uninstalled. Warning: Failed to scan C:\Users\Peter.Annandale. Details: Access to the path 'C:\Users\Peter.Annandale\Application Data' is denied. Error: Failed to load template from D:\Shared\Source\Repos\Temp\template.config\template.json. Details: The template root is outside the specified install source location. Error: Failed to load template from D:\Shared\Source\Repos\Temp\template.config/template.json: Source './src/' in template does not exist. Source './tests/' in template does not exist.

Error: Failed to load template from D:\Shared\Source\Repos\Test\CleanArchitectureWithBlazorServer.template.config\template.json. Details: The template root is outside the specified install source location. Success: sayedha.templates::1.0.6 installed the following templates: Template Name Short Name Language Tags


clitool clitool [C#] Console/Tool idehostjson idehostjson [C#] template mytemplate mytemplate [C#] Console/Tool templatejson templatejson [C#] template templatepackcsproj templatepackcsproj [C#] template

PS D:\Shared\Source\Repos\Test\CleanArchitectureWithBlazorServer.template.config> dotnet new templatejson Creating this template will make changes to existing files: Overwrite ./template.json

To create the template anyway, run the command with '--force' option: dotnet new templatejson --force

For details on the exit code, refer to https://aka.ms/templating-exit-codes#73 PS D:\Shared\Source\Repos\Test\CleanArchitectureWithBlazorServer.template.config> dotnet new templatejson --force The template "templatejson" was created successfully.

PS D:\Shared\Source\Repos\Test\CleanArchitectureWithBlazorServer.template.config> dotnet new --install ./ Warning: use of 'dotnet new --install' is deprecated. Use 'dotnet new install' instead. For more information, run: dotnet new install -h

The following template packages will be installed: D:\Shared\Source\Repos\Test\CleanArchitectureWithBlazorServer.template.config

D:\Shared\Source\Repos\Test\CleanArchitectureWithBlazorServer.template.config is already installed. To reinstall the same version of the template package, use '--force' option: dotnet new install D:\Shared\Source\Repos\Test\CleanArchitectureWithBlazorServer.template.config --force

For details on the exit code, refer to https://aka.ms/templating-exit-codes#106 PS D:\Shared\Source\Repos\Test\CleanArchitectureWithBlazorServer.template.config> dotnet new list These templates matched your input:

Template Name Short Name Language Tags


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... 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 ASP.NET Core with React.js and R... reactredux [C#] Web/MVC/SPA Blazor Hero - Clean Architecture... BlazorHero.CleanArchitecture [C#] Web/Blazor/WebAssembly/WebApi/CleanArchitecture 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 clitool clitool [C#] Console/Tool 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 idehostjson idehostjson [C#] template MSBuild Directory.Build.props file buildprops MSBuild/props MSBuild Directory.Build.targets ... 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 mytemplate mytemplate [C#] Console/Tool 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 Class Library Razor Component razorcomponent [C#] Web/ASP.NET Razor Page page [C#] Web/ASP.NET Solution File sln,solution Solution templatejson templatejson [C#] template templatepackcsproj templatepackcsproj [C#] template Web Config webconfig Config Windows Forms App winforms [C#],VB Common/WinForms Windows Forms Class Library winformslib [C#],VB Common/WinForms Windows Forms Control Library winformscontrollib [C#],VB Common/WinForms Worker Service worker [C#],F# Common/Worker/Web WPF Application wpf [C#],VB Common/WPF WPF Class Library wpflib [C#],VB Common/WPF WPF Custom Control Library wpfcustomcontrollib [C#],VB Common/WPF WPF User Control Library wpfusercontrollib [C#],VB Common/WPF xUnit Test Project xunit [C#],F#,VB Test/xUnit

PS D:\Shared\Source\Repos\Test\CleanArchitectureWithBlazorServer.template.config> dotnet new --install ./ --force Warning: use of 'dotnet new --install' is deprecated. Use 'dotnet new install' instead. For more information, run: dotnet new install -h

The following template packages will be installed: D:\Shared\Source\Repos\Test\CleanArchitectureWithBlazorServer.template.config

D:\Shared\Source\Repos\Test\CleanArchitectureWithBlazorServer.template.config is already installed, it will be replaced with latest version. D:\Shared\Source\Repos\Test\CleanArchitectureWithBlazorServer.template.config was successfully uninstalled. Warning: Failed to scan C:\Users\Peter.Annandale. Details: Access to the path 'C:\Users\Peter.Annandale\Application Data' is denied. Error: Failed to load template from D:\Shared\Source\Repos\Temp\template.config\template.json. Details: The template root is outside the specified install source location. Error: Failed to load template from D:\Shared\Source\Repos\Test\CleanArchitectureWithBlazorServer.template.config\template.json. Details: The template root is outside the specified install source location. Error: Failed to load template from D:\Shared\Source\Repos\Temp\template.config/template.json: Source './src/' in template does not exist. Source './tests/' in template does not exist.

No templates were found in the package D:\Shared\Source\Repos\Test\CleanArchitectureWithBlazorServer.template.config. PS D:\Shared\Source\Repos\Test\CleanArchitectureWithBlazorServer.template.config>

Regards..

neozhu commented 1 year ago

@buda56 I'm sorry, I haven't researched it either. I copied this template too. You know you figured it out yourself.

buda56 commented 1 year ago

@neozhu Have you ever created a template for visual studio, if so can you provide a step by step including any folder changes as to howe you did it?? I am assuming that the template is made from inside the clone of the project from github?

Regards Peter

neozhu commented 1 year ago

Hi Peter, I copied this project: https://github.com/blazorhero/CleanArchitecture. I have not created the template you mentioned, nor have I attempted to modify the project's namespace. These tasks would require the use of another code generation plugin, and I haven't tested whether different namespaces would work properly.

buda56 commented 1 year ago

@neozhu ahh okay, now I understand. I'm fine with cloning and keeping the namespace. My main interest is your plugin for creating the boilerplate code for additional Entities.

Regards Peter