microsoft / mindaro

Bridge to Kubernetes - for Visual Studio and Visual Studio Code
MIT License
307 stars 106 forks source link

The user property 'LocalLaunchProfile' is missing or invalid #165

Open shalev123d opened 3 years ago

shalev123d commented 3 years ago

Hi,

When trying to run my project in Visual Studio using the "Bridge to Kubernetes" profile, The "Create profile for Bridge to Kubernetes" configuration page pops up which let me choose the service I'm working on etc. After hitting "Save and Debug", the same configuration window pops up once again, and after filling again the information regarding which service I'm working on and isolation mode, I get an error saying "The user property 'LocalLaunchProfile' is missing or invalid"

image

I have found this message in the logs:

{
  "timestamp": "2021-04-21 14-50-25.717",
  "message": "Show the configuration dialog",
  "exception": {
    "ClassName": "System.InvalidOperationException",
    "Message": "The user property 'LocalLaunchProfile' is missing or invalid",
    "Data": null,
    "InnerException": null,
    "HelpURL": null,
    "StackTraceString": "   at Microsoft.VisualStudio.Kubernetes.Debugging.Core.Services.Context.DebuggingContext.ValidateConfig()\r\n   at Microsoft.VisualStudio.Kubernetes.Debugging.Core.Services.Context.LocalConfigDebuggingContext.ValidateConfig()\r\n   at Microsoft.VisualStudio.Kubernetes.Debugging.Core.Services.Context.LocalConfigDebuggingContext.<SerializeAsync>d__7.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)\r\n   at Microsoft.VisualStudio.Kubernetes.Debugging.Core.Services.Configuration.ConfigurationDialogService.<>c__DisplayClass8_0.<<ShowConfigurationDialogAsync>b__1>d.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Microsoft.VisualStudio.Kubernetes.Debugging.Core.Services.Logging.PerfLoggerExtensions.<ExecuteOperationAsync>d__3`1.MoveNext()",
    "RemoteStackTraceString": null,
    "RemoteStackIndex": 0,
    "ExceptionMethod": "8\nValidateConfig\nMicrosoft.VisualStudio.Kubernetes.Debugging.Core, Version=2.1.99.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\nMicrosoft.VisualStudio.Kubernetes.Debugging.Core.Services.Context.DebuggingContext\nVoid ValidateConfig()",
    "HResult": -2146233079,
    "Source": "Microsoft.VisualStudio.Kubernetes.Debugging.Core",
    "WatsonBuckets": null
  },
  "operationName": "ConfigurationDialogService.ShowConfigurationDialogAsync",
  "stage": "End",
  "elapsedTime": "00:00:17.6105969",
  "completionState": "Error"
}

Visual Studio Version - 16.9.1 Bridge to Kubernetes Version - 2.1.20210327.1 With much thanks in advance!

lolodi commented 3 years ago

Hi @shalev123d! Thanks for reporting the issue! We'll investigate and report back when we have news.

danegsta commented 3 years ago

Hi @shalev123d, would it be possible to share the contents of the launchSettings.json file for your project (should be under Properties\launchSettings.json)?

shalev123d commented 3 years ago

Thanks for the response! Here's our launchSettings.json -

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iis": {
      "applicationUrl": "http://localhost:8787/MainAppApi",
      "sslPort": 0
    },
    "iisExpress": {
      "applicationUrl": "http://localhost:54468/",
      "sslPort": 0
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "AzureDevSpacesLocal",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "MainApp.Api": {
      "commandName": "IIS",
      "launchUrl": "webapi/v1/",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "ancmHostingModel": "OutOfProcess",
      "applicationUrl": "http://localhost:54469/"
    },
    "Docker": {
      "commandName": "Docker",
      "launchBrowser": true,
      "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
      "publishAllPorts": true
    },
    "Bridge to Kubernetes": {
      "commandName": "AzureDevSpacesLocal"
    }
  }
}
danegsta commented 3 years ago

It looks like the issue is that we're looking for a Kestrel launch profile (a profile with "commandName": "Project") as IIS profiles aren't supported by the Bridge connection manager. Can you try adding the following entry to your profiles in launchSettings.json and see if that gets you unblocked?

"MainApp.Api.Kestrel": {
  "commandName": "Project",
  "launchBrowser": true,
  "environmentVariables": {
    "ASPNETCORE_URLS": "http://localhost:54469",
    "ASPNETCORE_ENVIRONMENT": "Development"
  }
}
shalev123d commented 3 years ago

It seems to be running now! Just wondering, if for some reason I would want to change the default profile to Docker for example instead of IIS, should I just add a "Docker.Kestrel" with a '"commandName": "Project"' ?

Thank you very much! @danegsta

danegsta commented 3 years ago

For launch profiles, the profile names are arbitrary (the Kestrel profile on a new project actually defaults to having the same name as the project); the value of "commandName" determines what a given launch profile will do when invoked (and even that can depend on the specific project as "commandName": "Project" launches a Kestrel web server for an Asp.NET project, but is also used to launch a standard console app without any web components).

For projects with Docker support added, launch profiles with "commandName": "Docker" will build and run the project in the local Dockerfile (it's entirely possible to define multiple profiles with different configurations to test different scenarios for a project).

As far as the default profile in a project, that is a user specific setting that gets persisted to a .csproj.user file in the same folder as your project's .csproj file and isn't exposed in the VS UI; it gets updated whenever you select a new profile in the dropdown list such that it'll be remembered the next time you open the project. The .csproj.user file is in the default .gitignore for a VS project as it generally wouldn't be ideal to check-in.

shalev123d commented 3 years ago

@danegsta Thanks! Just one thing if I may,

Would we be able to choose the default profile manually? If I want to run my local project (with bridge) using a local container (the Docker profile for example), how can I configure it? Because I need to run the application with "commandName": "Docker" but it forces me to use "Project" instead, which defaults to my local workstation.

shalev123d commented 3 years ago

Should I open a feature request about that?

We just want to be able to develop on containers, as it's the main goal eventually, to ship the same container into the cluster so we minimize differences between the local version and the containerized version.

(if there's something similar to VSCode tasks.json and launch.json where you can configure custom launch tasks that would be great!)

amsoedal commented 3 years ago

Hi @shalev123d, the work for attaching to containerized workloads is currently in progress. I will make a note to update this thread once the feature is released. Thanks for reaching out to us about that!

shalev123d commented 3 years ago

@amsoedal Much appreciated!