GithubHelp home page GithubHelp logo

Comments (4)

markjprice avatar markjprice commented on May 7, 2024 1

At the bottom of page 159, in step 6, before the statement that sets the base directory, and a statement to output the current directory so that you can see where it is looking for appsettings.json, as shown in the following code:

Console.WriteLine(Directory.GetCurrentDirectory());

builder.SetBasePath(Directory.GetCurrentDirectory())
  .AddJsonFile("appsettings.json", 
   optional: true, reloadOnChange: true);

You should see that when running the console app using dotnet run, the current directory is the project folder Instrumenting. But if you were to run the console app using Visual Studio 2022, the current directory is Instrumenting\bin\*\net6.0.

from cs10dotnet6.

majew7 avatar majew7 commented on May 7, 2024

Thanks for replying @markjprice.

Scenario A: Command Line
Yes, I added the additional Console.WriteLine() and upon executing dotnet run I see the running directory as: .../code/Other/Chapter04/Instrumenting.

Scenario B: Visual Studio 2022 for Mac w Debugger
And yes, running the same code in Visual Studio with the debugger, I see the running directory is .../code/Other/Chapter04/Instrumenting/bin/Debug/net6.0.

Confirmed for both scenarios.


But the scenario, that this sub-section is highlighting, is VSC w debugger.

Scenario C: Visual Studio Code w Debugger
When I tried this third scenario, I oddly saw this as the current directory: .../code/Other/Chapter04.

So I want back to my launch.json and saw that cwd was set like this:

...
"program": "${workspaceFolder}/Instrumenting/bin/Debug/net6.0/Instrumenting.dll",
"cwd": "${workspaceFolder}",
...

I changed it to this:

...
"program": "${workspaceFolder}/Instrumenting/bin/Debug/net6.0/Instrumenting.dll",
"cwd": "${workspaceFolder}/Instrumenting",
...

and then finally I saw VSC Debugger read from appsettings.json and set ts correctly. I had previously added the launch.json new json object entry myself because upon selecting the Instrumenting as the active OmniSharp project, I did not see a pop-up warning message saying that required assets are missing, and thus could not click Yes to add them. I believe I didn't see it, because it did not pop up at all.

My .vscode folder is here .../code/Other/Chapter04/.vscode/launch.json.

Q3) Is my .vscode folder where you expect to have been created? Thanks!

from cs10dotnet6.

markjprice avatar markjprice commented on May 7, 2024

Each project normally has its own .vscode folder, so it should have been .../code/Other/Chapter04/Instrumenting/.vscode/launch.json. If you miss the popup, you should then be able to select the bell icon to reveal it again. But for the past couple of months the C# extension had a bug that could have caused it not to correctly create the .vscode folder: #11

from cs10dotnet6.

majew7 avatar majew7 commented on May 7, 2024

Thanks for your response @markjprice. Ok, no, you do not expect .vscode folder to be at the workspace-level.

On my machine, the Required Assets Popup won't appear, if the .vscode folder already exists at the workspace level. However, when I delete the .../code/Other/Chapter04/.vscode/ folder, and select the next active project (ie. OmniSharp: Select Project), then the popup will reappear.

I will keep playing with VS Code and the C# Extension over the next week. Currently my hunch is that the C# Extension is incorrectly creating .vscode folders at the workspace-level, rather than the project-level.

My C# extension is v1.24.0, which I've uninstalled and installed a few times now.

from cs10dotnet6.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.