staticwebdev / blazor-starter

A starter template in C# APIs and Blazor for Azure Static Web Apps
219 stars 111 forks source link

Visual Studio 2022 and Local Authentication #30

Open scottkuhl opened 2 years ago

scottkuhl commented 2 years ago

The instructions in the README tell you to start the Static Web Apps CLI in the Visual Studio Code instructions, but they don't mention it in the Visual Studio 2022 instructions. Visual Studio 2022 will need the Static Web Apps CLI running, and you will need to access it on its proxy port if you try to work with authentication locally.

To get Visual Studio 2022 working with authentication locally I needed to:

  1. Start the Static Web Apps CLI and leave it running: swa start http://localhost:5000
  2. Access the app on port 4280 instead of 5000.

A more integrated solution was to:

  1. Add "launchUrl": "http://localhost:4280/", to the launchSettings.json client profile.
  2. Install the Command Task Runner (64-bit) extension.
  3. Create a StaticWebApp.cmd file in the solution root with swa start http://localhost:5000 in it.
  4. Create a commands.json file in the solution root to run StaticWebApp.cmd when the project opens:

{ "commands": { "Tools": { "fileName": "cmd.exe", "workingDirectory": ".", "arguments": "/c StaticWebApp.cmd" } }, "-vs-binding": { "ProjectOpened": [ "Tools" ] } }

Fix: I would like to see running the Static Web Apps CLI with Visual Studio 2022 addressed in the README or another solution implemented to get authentication working locally.

snow-jallen commented 2 years ago

Better integration with VS 2022 would be wonderfully nice. Yes please.