Comments (4)
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.
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.
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.
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)
- Chapter04 composite HOT 1
- vs4win/Chapter04/PrimeFactorsLib/Primes.cs ugh
- Chapter 1 - Setting .NET 5 as the target HOT 1
- Chapter 16 section "Implementing open api analyzers and conventions" HOT 1
- Exploring the PowerShell language has label 3, but no content HOT 3
- Chapter 14 Layout not being applied to Razor pages HOT 4
- Chapter07 Packaging and Distributing .NET Types | Page 296 HOT 1
- Chapter 1 - Adding .NET Interactive Notebooks to VSCode HOT 2
- Chapter07 Packaging and Distributing .NET Types HOT 5
- Chapter 14 - Unable to create authentication database for SQL Server LocalDB HOT 3
- Chapter 01 Downloading and installing Visual Studio 2022 for Windows [pp 6-7] HOT 1
- Chapter 2 notebook has code related to nullable value HOT 1
- Why does 0.1+0.2 not equal 0.3, but 0.1+0.3 equals 0.4? And why we need the M to declare a decimal literal value? HOT 2
- Ch 02 - Following the DRY principle while completing one of the coding exercises HOT 1
- Thank you Mark HOT 1
- Polyglot Notebook has replaced .NET Interactive HOT 1
- SQLite3 - StringLength Attribute Not Honored HOT 1
- Chapter 17 A second operation was started on this context instance before a previous operation completed HOT 11
- how can i get code in charpter 21 in your book about wpf programing. HOT 1
- Visual Studio Code .md instructions on use are missing HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cs10dotnet6.