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

VS Code fails to generate launch.json when there are ignorable errors in project.json #577

Closed
gregg-miskelly opened this issue Jul 15, 2016 · 9 comments

Comments

@gregg-miskelly
Copy link
Contributor

gregg-miskelly commented Jul 15, 2016

Steps to reproduce

  1. dotnet new
  2. Open project.json in an editor, add a trailing comma after the 'Microsoft.NETCore.App' dependency
  3. dotnet restore
  4. dotnet build
  5. Open the folder in VS Code
  6. When asked if assets should be generated, say 'yes'

Expected behavior

Since apparently the CLI ignores the trailing ',' in the project.json file, the C# extension should ignore it to and generate launch.json and tasks.json. Or if that is really hard to do, maybe an error indicating the problem.

Actual behavior

Only tasks.json is generated

@DustinCampbell
Copy link
Member

The basic problem here is that Microsoft.ProjectModel is not resilient to the error, which means that OmniSharp can't process it. The proper generation of the launch.json requires querying OmniSharp to determine where the executable will be produced. So, a simple syntax error can make the whole thing fall apart.

I'll take a closer look to see if there's anything we can do. It seems like dotnet build gets around this somehow.

@gregg-miskelly
Copy link
Contributor Author

@DustinCampbell makes sense. If this is hard to fix, maybe we can just warn the user that there are syntax errors?

@chuckries
Copy link
Contributor

+1

I am seeing launch.json generation fail against the default project.json created by the .NET Core Visual Studio tools. The project.json appears to be valid.

Repro:

  1. From VS IDE, create a new .NET Core Web Application
  2. Open the project directory in VS Code
  3. When VS Code prompts for asset generation, say yes

Expected: launch.json and tasks.json are created.
Actual: tasks.json is created but launch is not.

Here is the project.json:

{
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.0",
      "type": "platform"
    },
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.0",
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Logging": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0"
  },

  "tools": {
    "BundlerMinifier.Core": "2.0.238",
    "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "portable-net45+win8"
      ]
    }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "Views",
      "Areas/**/Views",
      "appsettings.json",
      "web.config"
    ]
  },

  "scripts": {
    "prepublish": [ "bower install", "dotnet bundle" ],
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}

The exception is being thrown from JSON.parse(...) in hasWebServerDependency in assets.ts. @rajkumar42 do you have any ideas?

@rajkumar42
Copy link
Contributor

Looks like it is a known issue, I'll be sending out a PR shortly.
nodejs/node-v0.x-archive#1918

@gregg-miskelly
Copy link
Contributor Author

Correct me if I am wrong, but I think we accidentally had this issue track two different things -- the BOM issue that Rajkumar just fixed, and the original issue that CTI found, and I opened the bug for -- that we don't provide any good feedback if there are json syntax errors. Reopening to keep tracking the original issue.

@DustinCampbell
Copy link
Member

You're totally right. Sorry about that.

@DustinCampbell
Copy link
Member

Note: I've started looking at #556, and have found that the example project also ends up failing calls to JSON.parse() due to trailing commas.

@rchande
Copy link

rchande commented Jun 13, 2018

Project.json support is deprecated. I don't think we need to fix this.

@DenitsaAGeorgieva
Copy link

you don't? Because it happens all the time. And for beginners that don't know everything you know, it's really hard and frustrating to try and solve this issue, sets you back for a long time while you try to figure out on your own what is happening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants