Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.

Commit 8642e60

Browse files
author
Peter Huene
authored
Merge pull request #9766 from peterhuene/fix-default-proj-guid
Fix dotnet sln add for multitargeted C# and VB projects.
2 parents c198433 + 96c9dc3 commit 8642e60

File tree

9 files changed

+141
-1
lines changed

9 files changed

+141
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
6+
</PropertyGroup>
7+
8+
</Project>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System;
2+
3+
namespace MultitargetedCS
4+
{
5+
class Program
6+
{
7+
static void Main(string[] args)
8+
{
9+
Console.WriteLine("Hello World!");
10+
}
11+
}
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<Compile Include="Program.fs" />
10+
</ItemGroup>
11+
12+
</Project>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Learn more about F# at http://fsharp.org
2+
3+
open System
4+
5+
[<EntryPoint>]
6+
let main argv =
7+
printfn "Hello World from F#!"
8+
0 // return an integer exit code
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<RootNamespace>MultitargetedVB</RootNamespace>
6+
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
7+
</PropertyGroup>
8+
9+
</Project>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Imports System
2+
3+
Module Program
4+
Sub Main(args As String())
5+
Console.WriteLine("Hello World!")
6+
End Sub
7+
End Module
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.26124.0
5+
MinimumVisualStudioVersion = 15.0.26124.0
6+
Global
7+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
8+
Debug|Any CPU = Debug|Any CPU
9+
Debug|x64 = Debug|x64
10+
Debug|x86 = Debug|x86
11+
Release|Any CPU = Release|Any CPU
12+
Release|x64 = Release|x64
13+
Release|x86 = Release|x86
14+
EndGlobalSection
15+
GlobalSection(SolutionProperties) = preSolution
16+
HideSolutionNode = FALSE
17+
EndGlobalSection
18+
EndGlobal

build/DependencyVersions.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<MicrosoftNETCoreCompilersPackageVersion>$(MicrosoftCodeAnalysisCSharpPackageVersion)</MicrosoftNETCoreCompilersPackageVersion>
2424
<MicrosoftCodeAnalysisBuildTasksPackageVersion>$(MicrosoftCodeAnalysisCSharpPackageVersion)</MicrosoftCodeAnalysisBuildTasksPackageVersion>
2525
<MicrosoftNetCompilersNetcorePackageVersion>$(MicrosoftCodeAnalysisCSharpPackageVersion)</MicrosoftNetCompilersNetcorePackageVersion>
26-
<MicrosoftNETSdkPackageVersion>2.1.400-preview-63126-05</MicrosoftNETSdkPackageVersion>
26+
<MicrosoftNETSdkPackageVersion>2.1.400-preview-63130-06</MicrosoftNETSdkPackageVersion>
2727
<MicrosoftNETBuildExtensionsPackageVersion>$(MicrosoftNETSdkPackageVersion)</MicrosoftNETBuildExtensionsPackageVersion>
2828
<MicrosoftNETSdkRazorPackageVersion>2.1.1</MicrosoftNETSdkRazorPackageVersion>
2929
<MicrosoftNETSdkWebPackageVersion>2.1.400-preview1-20180705-1834985</MicrosoftNETSdkWebPackageVersion>

test/dotnet-sln-add.Tests/GivenDotnetSlnAdd.cs

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,72 @@ public void WhenProjectWithAdditionalConfigurationsIsAddedSolutionDoesNotMapThem
10121012
.Should().BeVisuallyEquivalentTo(ExpectedSlnFileAfterAddingProjectWithAdditionalConfigs);
10131013
}
10141014

1015+
[Fact]
1016+
public void ItAddsACSharpProjectThatIsMultitargeted()
1017+
{
1018+
var solutionDirectory = TestAssets
1019+
.Get("TestAppsWithSlnAndMultitargetedProjects")
1020+
.CreateInstance()
1021+
.WithSourceFiles()
1022+
.Root
1023+
.FullName;
1024+
1025+
var slnFullPath = Path.Combine(solutionDirectory, "App.sln");
1026+
var projectToAdd = Path.Combine("MultitargetedCS", "MultitargetedCS.csproj");
1027+
1028+
new DotnetCommand()
1029+
.WithWorkingDirectory(solutionDirectory)
1030+
.ExecuteWithCapturedOutput($"sln add {projectToAdd}")
1031+
.Should()
1032+
.Pass()
1033+
.And
1034+
.HaveStdOutContaining(string.Format(CommonLocalizableStrings.ProjectAddedToTheSolution, projectToAdd));
1035+
}
1036+
1037+
[Fact]
1038+
public void ItAddsAVisualBasicProjectThatIsMultitargeted()
1039+
{
1040+
var solutionDirectory = TestAssets
1041+
.Get("TestAppsWithSlnAndMultitargetedProjects")
1042+
.CreateInstance()
1043+
.WithSourceFiles()
1044+
.Root
1045+
.FullName;
1046+
1047+
var slnFullPath = Path.Combine(solutionDirectory, "App.sln");
1048+
var projectToAdd = Path.Combine("MultitargetedVB", "MultitargetedVB.vbproj");
1049+
1050+
new DotnetCommand()
1051+
.WithWorkingDirectory(solutionDirectory)
1052+
.ExecuteWithCapturedOutput($"sln add {projectToAdd}")
1053+
.Should()
1054+
.Pass()
1055+
.And
1056+
.HaveStdOutContaining(string.Format(CommonLocalizableStrings.ProjectAddedToTheSolution, projectToAdd));
1057+
}
1058+
1059+
[Fact]
1060+
public void ItAddsAnFSharpProjectThatIsMultitargeted()
1061+
{
1062+
var solutionDirectory = TestAssets
1063+
.Get("TestAppsWithSlnAndMultitargetedProjects")
1064+
.CreateInstance()
1065+
.WithSourceFiles()
1066+
.Root
1067+
.FullName;
1068+
1069+
var slnFullPath = Path.Combine(solutionDirectory, "App.sln");
1070+
var projectToAdd = Path.Combine("MultitargetedFS", "MultitargetedFS.fsproj");
1071+
1072+
new DotnetCommand()
1073+
.WithWorkingDirectory(solutionDirectory)
1074+
.ExecuteWithCapturedOutput($"sln add {projectToAdd}")
1075+
.Should()
1076+
.Pass()
1077+
.And
1078+
.HaveStdOutContaining(string.Format(CommonLocalizableStrings.ProjectAddedToTheSolution, projectToAdd));
1079+
}
1080+
10151081
private string GetExpectedSlnContents(
10161082
string slnPath,
10171083
string slnTemplate,

0 commit comments

Comments
 (0)