问题描述
创建一个新项目后(例如在.net核心中),解决方案的global.json看起来像
{
"projects":[" src"," test" ],
" sdk":{
" version":" 1.0.0-preview2-003131"
}
}
并且内部创建的新项目 src 文件夹,解决方案文件夹中存在一个物理文件夹。虽然global.json出现在解决方案
Items visual studio中的解决方案文件夹中,没有名为solution的物理文件夹物品存在。
现在,如果我添加一个单元测试项目,它只是在解决方案文件夹中创建,它不会创建任何名为&embsp = 测试。
然后我创建了一个测试文件夹,它不会出现在VS上,并且创建一个新的测试项目不会在测试物理文件夹中创建。另外,我可以在
下创建测试项目 src文件夹
如果我添加另一个新项目,新项目内部创建 src 文件夹。如果我添加任何项目(例如XMLFile),则将其添加到 解决方案项 解决方案
文件夹中。但是如果你添加测试项目,如果只是出现在解决方案文件夹下面
现在解决方案树是
和文件浏览器中的解决方案根文件夹如下所示
但是,我的问题是关于行为的差异。
- 为什么测试项目的行为不同
- 为什么测试会自动添加到global.json上?
我也注意到如果测试项目不在测试文件夹中,有时候,它没有找到xunit或nunit测试,但是它找到了MSTest测试。所以,我的观点是如何 test 在global.json
帮助我们?
After creating a new project (example is in .net core) the global.json of the solution looks like that
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-preview2-003131"
}
}
And the new project created inside src folder and there is a physical folder exists inside the solution folder. Although the global.json appears inside Solution Items solution folder in the visual studio, no physical folder named solution items exists.
Now if i add a unittest project it creates just inside the solution folder, it does not create any Solution Folder or Physical Folder named test.
Then i created a test folder it does not appear on VS and creating a new test project does not create within the test physical folder. In addition, I can create test project underneathsrc Folder
If i add an another new project the new project created inside src folder. If I add any item (e.g. XMLFile) it add it within the Solution Items solution folder. But if you add test project if just appears underneath solution folder
Now the solution tree is
and the solution root folder in file explorer looks like below
However, my question is about the discrepancies of the behaviours.
- Why the behaviour is different for test projects
- Why is the test added on global.json automatically?
I have also noticed that if the test project is not inside the test folder, sometimes, it does not find xunit or nunit tests, but it finds the MSTest tests. So, my point is how the test in global.json helping us?
这篇关于试图了解global.json在Visual Studio中的工作原理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!