Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visual Studio development of Dapr apps #401

Closed
RicardoNiepel opened this issue Sep 21, 2020 · 7 comments
Closed

Visual Studio development of Dapr apps #401

RicardoNiepel opened this issue Sep 21, 2020 · 7 comments
Labels
kind/enhancement New feature or request P2

Comments

@RicardoNiepel
Copy link

Currently only the development of Dapr applications in VS Code and IntelliJ is documented:
https://github.com/dapr/docs/tree/master/howto#developer-tooling

There should also be something similiar for Visual Studio 2019:

  • Enable debugging / "F5 experience" of Dapr applications in Visual Studio
  • Ensure that this include a story of multiple Dapr applications inside one solution and starting multiple of them
  • Ensure that the Yeoman Dapr generator for C# Dapr applications is generating all things needed for efficient development in Visual Studio

If Visual Studio does not support a productive development, we need an extension approach, like we have for VSCode: https://github.com/microsoft/vscode-dapr

Tye with Dapr integration is going into this direction - but it is only experimental.

@ddobric
Copy link
Contributor

ddobric commented Oct 2, 2020

When looking into Tye, have to say that Tye extrimely simplifies the deployment. For this reason, I propose similar concept in dapr.
For example:

dapr deploy <path>

This would be a great simplification.

@vinayada1 vinayada1 added P2 kind/enhancement New feature or request question Further information is requested and removed question Further information is requested labels Oct 27, 2020
@vinayada1
Copy link
Contributor

Thanks. Could you please send your feedback on https://docs.microsoft.com/en-us/visualstudio/ide/suggest-a-feature?view=vs-2019?

@Fabian-Schmidt
Copy link
Contributor

Hi, I have played around with Visual Studio and Dapr applications.
I found two options to achive a F5 debug experience in Visual Studio.

Dotnet app starting Dapr

Modify your .NET app to start Dapr process

Need Nuget package System.CommandLine.

public static void Main(string[] args) {
var rootCommand = new RootCommand
{
    new Option<string[]>("--DAPR_CMD")
};
rootCommand.Handler = CommandHandler.Create((string[] DAPR_CMD) =>
{
    if (DAPR_CMD != null && DAPR_CMD.Length > 0)
    {
        var cmd = DAPR_CMD[0];
        var cmdArgs = DAPR_CMD[1..];
        if (!string.IsNullOrWhiteSpace(cmd))
        {
            DaprProcess = new System.Diagnostics.Process
            {
                StartInfo =
                {
                    FileName = cmd,
                    Arguments = string.Join(' ', cmdArgs),
                }
            };
            DaprProcess.Start();
        }
    }
});
rootCommand.Invoke(args);

The necessary launchSettings.json

"Dapr": {
  "commandName": "Project",
  "commandLineArgs": "--DAPR_CMD dapr run --app-id mydaprapp --components-path ./components/ --app-port 5000 --dapr-http-port 5005 --dapr-grpc-port 5006",
  "launchUrl": "swagger",
  "environmentVariables": {
    "DAPR_HTTP_PORT": "5005",
    "DAPR_GRPC_PORT": "5006",
    "ASPNETCORE_ENVIRONMENT": "Development"
  },
  "dotnetRunMessages": "true",
  "applicationUrl": "https://localhost:5001;http://localhost:5000"
}

Use VS extension

Need PowerShell 7 / Core installed (Example: dotnet tool install --global PowerShell)

Need the Visual Studio extension Microsoft Child Process Debugging Power Tool installed.

Activate Child Process Debugging Settings and configure:

Enabled Process name Action Debugger Type
Yes <All other processeses> Do not debug <Inherit from parent process>
Yes dapr.exe Attach debugger Native
Yes dotnet.exe Attach debugger Native
Yes myapp.exe Attach debugger Managed (.NET Core, .NET 5+)

The necessary launchSettings.json

"Dapr-PWSH": {
  "commandName": "Executable",
  "executablePath": "pwsh",
  "commandLineArgs": "-Command \"dapr run --app-id mydaprapp --components-path ./components/ --app-port 5000 --dapr-http-port 5005 --dapr-grpc-port 5006 -- dotnet run --no-build\"",
  "workingDirectory": ".",
  "environmentVariables": {
    "ASPNETCORE_ENVIRONMENT": "Development"
  },
  "nativeDebugging": true
}

@wjkhappy14
Copy link

thks

@DanielHazlewood
Copy link

DanielHazlewood commented May 28, 2022

Could we include something in the documentation for this? So far only IntelliJ and VSCode is documented. This seems a bit strange considering the flagship nature of Visual Studio 2022 and this being a Microsoft driven project.

@toresenneseth
Copy link

Just starting to explore Dapr, and came across Dapr sidekick which seems to make debugging in VS very easy. Might get me into trouble...don't know yet :)

@Joffreyvl
Copy link

@Fabian-Schmidt I can't seem to figure out the extension way

I have the following settings

Screenshot 2024-03-20 120627

"Dapr": {
  "commandName": "Executable",
  "executablePath": "powershell",
  "commandLineArgs": "-Command \"dapr run --app-id pmo-api -- dotnet run --urls http://localhost:5000\"",
  "workingDirectory": ".",
  "nativeDebugging": true,
  "environmentVariables": {
  }
},

Am I missing something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement New feature or request P2
Projects
None yet
Development

No branches or pull requests

8 participants