解决方案的项目位于解决方案文件夹之外 [英] Solution has projects that are located outside the solution folder

查看:188
本文介绍了解决方案的项目位于解决方案文件夹之外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试通过选择文件 | 添加到源代码管理,将解决方案添加到本地存储库,但收到以下消息.

I tried to add my solution to the local repository by selecting File|Add to Source Control, but I got the following message.

源代码控制-Git
当前解决方案的项目位于solution文件夹之外.这些项目将不受Git存储库中的源代码控制.要将所有项目添加到单个Git存储库中,请将所有项目合并到一个文件夹下.

Source Control - Git
The current solution has projects that are located outside the solution folder.These projects will not be source controlled in Git repository.To add all the projects to a single Git repository please consolidate all projects under a single folder.

但是,我所有的项目都在我的解决方案文件夹中.我唯一不确定的是,我向我的一个项目中添加了NuGet程序包,但在任何地方都看不到它.在项目的csproj文件中,其显示如下.

However, all of my projects are within my solution folder. The only thing I'm uncertain about is that I added a NuGet package to one of my projects and I don't see that anywhere. It appears as the following in the project's csproj file.

<ItemGroup>
  <PackageReference Include="Microsoft.Win32.Registry" Version="4.5.0" />
</ItemGroup>

有人知道这是否可能导致此错误吗?我可以单击确定",它创建了本地存储库,但我想将其放在GitHub上,所以我想弄清楚问题出在哪里.

Does anyone know if that could cause this error? I was able to click OK and it created the local repository, but I want to put it on GitHub and so I'd like to figure out what the issue is.

还有一个问题,当向GitHub添加这样的解决方案时,我通常会包括这样的软件包吗?我期望有一个packages文件夹,但没有得到.

As an additional question, when adding a solution like this to GitHub, would I normally include any packages like this? I expected a packages folder but I didn't get one.

以下是解决方案的屏幕截图:

Here's a screenshot of the solution:

这是我的解决方案文件:

And here's my solution file:

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28922.388
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Toxic", "Toxic\Toxic.csproj", "{DEAAC3F5-B48F-4601-ADC7-ECFE1519A841}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Toxic.Desktop", "Toxic.Desktop\Toxic.Desktop.csproj", "{A4EAA8D5-C085-4960-A871-74F68F6F9BC7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Toxic.Web",    "Toxic.Web\Toxic.Web.csproj", "{49E8312B-506E-4AC1-8524-37BB601EC889}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ToxicTests", "ToxicTests\ToxicTests.csproj", "{131B2077-A4C2-48EA-A1E1-8CA1A38097BD}"
EndProject
Global
    GlobalSection(SolutionConfigurationPlatforms) = preSolution
        Debug|Any CPU = Debug|Any CPU
        Release|Any CPU = Release|Any CPU
    EndGlobalSection
    GlobalSection(ProjectConfigurationPlatforms) = postSolution
        {DEAAC3F5-B48F-4601-ADC7-ECFE1519A841}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
        {DEAAC3F5-B48F-4601-ADC7-ECFE1519A841}.Debug|Any CPU.Build.0 = Debug|Any CPU
        {DEAAC3F5-B48F-4601-ADC7-ECFE1519A841}.Release|Any CPU.ActiveCfg = Release|Any CPU
        {DEAAC3F5-B48F-4601-ADC7-ECFE1519A841}.Release|Any CPU.Build.0 = Release|Any CPU
        {A4EAA8D5-C085-4960-A871-74F68F6F9BC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
        {A4EAA8D5-C085-4960-A871-74F68F6F9BC7}.Debug|Any CPU.Build.0 = Debug|Any CPU
        {A4EAA8D5-C085-4960-A871-74F68F6F9BC7}.Release|Any CPU.ActiveCfg = Release|Any CPU
        {A4EAA8D5-C085-4960-A871-74F68F6F9BC7}.Release|Any CPU.Build.0 = Release|Any CPU
        {49E8312B-506E-4AC1-8524-37BB601EC889}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
        {49E8312B-506E-4AC1-8524-37BB601EC889}.Debug|Any CPU.Build.0 = Debug|Any CPU
        {49E8312B-506E-4AC1-8524-37BB601EC889}.Release|Any CPU.ActiveCfg = Release|Any CPU
        {49E8312B-506E-4AC1-8524-37BB601EC889}.Release|Any CPU.Build.0 = Release|Any CPU
        {131B2077-A4C2-48EA-A1E1-8CA1A38097BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
        {131B2077-A4C2-48EA-A1E1-8CA1A38097BD}.Debug|Any CPU.Build.0 = Debug|Any CPU
        {131B2077-A4C2-48EA-A1E1-8CA1A38097BD}.Release|Any CPU.ActiveCfg = Release|Any CPU
        {131B2077-A4C2-48EA-A1E1-8CA1A38097BD}.Release|Any CPU.Build.0 = Release|Any CPU
    EndGlobalSection
    GlobalSection(SolutionProperties) = preSolution
        HideSolutionNode = FALSE
    EndGlobalSection
    GlobalSection(ExtensibilityGlobals) = postSolution
        SolutionGuid = {2076F481-A5C7-4132-874E-47767C93475D}
    EndGlobalSection
EndGlobal

更新:

似乎每次将新项目添加到Source Control时,我都会收到此消息.似乎从根本上来说正在发生某些事情,因为我认为我没有引用任何外部文件,而我的解决方案文件表明了这一点.请注意,即使我收到此消息,它仍将解决方案添加到源代码管理中,并且一切似乎都可以正常进行.

It seems I now get this message every time I add a new project to Source Control. There seems to be something fundamentally going on here as I do not think I am referencing any external files, and I think my solution files show that. Note that even though I get this message, it still adds the solution to source control and everything seems to be working okay.

我没有命令行GIT程序,如果没有任何方法可以查看发生了什么情况,我真的希望不安装其他任何程序.

I do not have a command-line GIT program and would really prefer not to install anything else if there's any way to see what's going on without it.

推荐答案

请参阅下面的更新

从解决方案文件中的Visual Studio版本号来看,我假设您使用的是相对较新的发行版Visual Studio 2019(可能是预览版).

Judging by the Visual Studio version number in your Solution File, I will assume you are using Visual Studio 2019, a relatively recent release (possibly a Preview version).

这些是我的观察:

  1. 我正在使用Visual Studio Enterprise 16.20 (Preview 3.0),也正在使用Visual Studio Enterprise 16.1.6 (Release).

在任一版本的Visual Studio中,如果我在自定义目录下创建解决方案,就我而言,我使用c:\​​ Code \ Projects,则在尝试向其中添加新解决方案时会收到完全相同的警告源代码管理,然后选择随VS安装的Git版本. 请注意,我在此位置下有很多解决方案和目录.

In either version of Visual Studio, if I create a solution under a custom directory, in my case, I use c:\Code\Projects, I receive exactly the same warning when attempting to Add a new Solution to Source Control, and selecting the version of Git that was installed with VS. Note that I have many Solutions and Directories under this location.

如果我使用扩展名 Easy Git集成工具,在我的配置中,使用 Tortoise Git 作为其基础Git服务,我收到此警告消息.

If I use the extension Easy Git Integration tools, which in my configuration is using Tortoise Git as its underlying Git service, I do not get this warning message.

如果我单击警告消息,则所有文件都成功包含在后续的Git Commit中,并创建了一个有效的.gitignore文件.这包括使用所有有效文件成功创建并推送到GitHub.

If I OK the warning message, all files are successfully included in a subsequent Git Commit, and a valid .gitignore file is created. This includes successfully creating and pushing to GitHub, with all valid files.

如果我在Visual Studio默认值c:/username/source/repos中创建解决方案,我会收到来自PreviewRelease版本的警告视觉工作室. 请注意,我在此位置下没有其他解决方案或目录.

If I create the solution in the Visual Studio default of c:/username/source/repos, I do not receive a warning from either Preview or Release versions of Visual Studio. Note that I do not have any other Solutions or Directories under this location.

我建议你

a)确认父文件夹中没有git存储库;这有时会使Visual Studio感到困惑-您会发现几年前对此问题的引用.这很可能是您的问题.

a) Verify that there is not a git repository in a parent folder; this has sometimes confused Visual Studio - you will find references to this issue going back several years. This could well be your problem.

b)为了省心,请从命令行使用Git. Tortoise Git还与Visual Studio集成.

b) For peace of mind, use Git from a command line. Tortoise Git also has integration with Visual Studio.

如果您可以提供有关Visual Studio和Git版本,路径层次结构的更多信息,无论它是一个新的解决方案,它都可以帮助我们查明问题.

If you could provide some more information about Visual Studio and Git versions, path hierarchy, whether it is a new Solution, it might help us pinpoint the issue.

更新:

.Net Core 2.2项目也遇到了同样的问题,经过漫长的夜晚,我可以重现此问题.

I have also experienced the same issue with .Net Core 2.2 projects, and after a long night with coffee, I can reproduce this.

使用MS测试项目:

a)测试项目是解决方案中唯一的项目.

a) The Test Project is the only one in the solution.

b)下面显示了项目文件的内容.

b) The following shows the contents of the Project File.

c)尝试使用Add The Solution To Source Control,即Visual Studio默认的Git插件,显示有关源文件树的消息:

c) Attempting to Add The Solution To Source Control i.e. Visual Studio default Git plugin, displays the message regarding source file tree:

d)将源代码控制切换到第三方插件EZ-Git,可以轻松创建Git存储库.

d) Switching the source control to a third-party plugin, EZ-Git, allows the Git repository to be created without any issue.

e)我从没有git集成的zip文件恢复到存档版本,并删除了单独的软件包以查明原因.其结果是,当删除以下行时,Visual Studio的默认Git将成功创建存储库,而不会出现错误消息.

e) I reverted back to an archived version from a zip file, with no Git integration, and removed individual packages to isolate the cause; the result of this is that when the following line is removed, Visual Studio's default Git will successfully create a repository, with no error message.

<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" />

f)问题似乎在于Visual Studio如何处理MSTest.TestAdaptor的dll,这些dll在默认情况下被视为是Project的一部分,但它们位于c中的Solution文件夹结构之外:/Users/username/.nuget目录.

f) The issues appears to be how Visual Studio handles the dlls of the MSTest.TestAdaptor, which by default are treated as if they are part of the Project, yet they are located outside the Solution folder structure, in the c:/Users/username/.nuget directory.

g)将ExcludeAssets添加到MSTest.TestAdaptor将删除错误消息,但是很明显,这会破坏Visual Studio Test Runner.

g) Adding ExcludeAssets to the MSTest.TestAdaptor will remove the error message, but, fairly obviously, it breaks the Visual Studio Test Runner.

<PackageReference Include="MSTest.TestAdapter" Version="1.4.0">
  <ExcludeAssets>all</ExcludeAssets>
</PackageReference>

可能可以找到

It may be possible to find a combination of IncludeAssets, ExcludeAssets, and PrivateAssets to allow both proper functioning of Visual Studio Git, and Test Runner.

h)注意:上面详述的行为也适用于xUnit,即

h) NOTE: The behaviour as detailed above also applies to xUnit, i.e.

<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />

这表示该问题与Visual Studio和Microsoft TestPlatform的依赖关系有关.

Which indicates that the issue is related to dependencies around Visual Studio and the Microsoft TestPlatform.

这篇关于解决方案的项目位于解决方案文件夹之外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆