Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solution has projects that are located outside the solution folder

Tags:

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

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.

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>

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.

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:

enter image description here

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

UPDATE:

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.

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.

like image 671
Jonathan Wood Avatar asked Jun 09 '19 00:06

Jonathan Wood


People also ask

What is a solution folder?

A solution folder is a container for one or more related projects. You can create many folders within a Visual Studio solution, including nested folders. They appear in the Solution Explorer as expandable and collapsible sections.

How do I move a solution to another folder in Visual Studio?

Open solution explorer in Visual Studio and select the solution. and choose the new location.

How do I create a solution folder?

Create Solution FoldersRight-click on the solution → Add → New Solution Folder (or with the solution selected, click the Project menu → Add New Solution Folder):


1 Answers

Please see Update below

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).

These are my observations:

  1. I am using Visual Studio Enterprise 16.20 (Preview 3.0), and also Visual Studio Enterprise 16.1.6 (Release).

  2. 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.

  3. 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.

  4. 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.

  5. 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.

I would suggest you

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) For peace of mind, use Git from a command line. Tortoise Git also has integration with Visual Studio.

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.

UPDATE:

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

With an MS Test Project:

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

b) The following shows the contents of the Project File. Test Project file, showing References

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

Error Message from Git provider

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

EZ Git successfully creates repo

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) 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) 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) NOTE: The behaviour as detailed above also applies to xUnit, i.e.

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

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

like image 119
dmcquiggin Avatar answered Oct 12 '22 13:10

dmcquiggin