Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26006.2
MinimumVisualStudioVersion = 10.0.40219.1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<Solution />
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">

<PropertyGroup>
<TargetFramework>netstandard1.4</TargetFramework>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;

namespace Lib
{
public class Library
{
public static string GetMessage()
{
return "Message from Lib";
}
}
}
23 changes: 23 additions & 0 deletions test/dotnet-sln.Tests/GivenDotnetSlnAdd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1096,6 +1096,29 @@ public void WhenSolutionFolderIsPassedWithDirectorySeparatorFolderStructureIsCor
.Should().BeVisuallyEquivalentTo(expectedSlnContents);
}

[Theory]
[InlineData("sln", ".sln")]
[InlineData("sln", ".slnx")]
[InlineData("solution", ".sln")]
[InlineData("solution", ".slnx")]
public async Task WhenAddingProjectOutsideDirectoryItShouldNotAddSolutionFolders(string solutionCommand, string solutionExtension)
{
var projectDirectory = _testAssetsManager
.CopyTestAsset("TestAppWithSlnAndCsprojInParentDir", identifier: $"GivenDotnetSlnAdd-{solutionCommand}{solutionExtension}")
.WithSource()
.Path;
var projectToAdd = Path.Combine("..", "Lib", "Lib.csproj");
var cmd = new DotnetCommand(Log)
.WithWorkingDirectory(Path.Join(projectDirectory, "Dir"))
.Execute(solutionCommand, $"App{solutionExtension}", "add", projectToAdd);
cmd.Should().Pass();
// Should have no solution folders
ISolutionSerializer serializer = SolutionSerializers.GetSerializerByMoniker(Path.Join(projectDirectory, "Dir", $"App{solutionExtension}"));
SolutionModel solution = await serializer.OpenAsync(Path.Join(projectDirectory, "Dir", $"App{solutionExtension}"), CancellationToken.None);
solution.SolutionProjects.Count.Should().Be(1);
solution.SolutionFolders.Count.Should().Be(0);
}

private string GetExpectedSlnContents(
string slnPath,
string slnTemplateName,
Expand Down