diff --git a/TestAssets/TestProjects/SlnFileWithNoProjectReferencesAndFSharpProject/FSharpProject/App.config b/TestAssets/TestProjects/SlnFileWithNoProjectReferencesAndFSharpProject/FSharpProject/App.config
deleted file mode 100644
index 88fa4027b..000000000
--- a/TestAssets/TestProjects/SlnFileWithNoProjectReferencesAndFSharpProject/FSharpProject/App.config
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/TestAssets/TestProjects/SlnFileWithNoProjectReferencesAndFSharpProject/FSharpProject/AssemblyInfo.fs b/TestAssets/TestProjects/SlnFileWithNoProjectReferencesAndFSharpProject/FSharpProject/AssemblyInfo.fs
deleted file mode 100644
index d8b2c37d6..000000000
--- a/TestAssets/TestProjects/SlnFileWithNoProjectReferencesAndFSharpProject/FSharpProject/AssemblyInfo.fs
+++ /dev/null
@@ -1,41 +0,0 @@
-namespace FSharpProject.AssemblyInfo
-
-open System.Reflection
-open System.Runtime.CompilerServices
-open System.Runtime.InteropServices
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[]
-[]
-[]
-[]
-[]
-[]
-[]
-[]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// []
-[]
-[]
-
-do
- ()
\ No newline at end of file
diff --git a/TestAssets/TestProjects/SlnFileWithNoProjectReferencesAndFSharpProject/FSharpProject/FSharpProject.fsproj b/TestAssets/TestProjects/SlnFileWithNoProjectReferencesAndFSharpProject/FSharpProject/FSharpProject.fsproj
index cad8d59ce..43b200bd5 100644
--- a/TestAssets/TestProjects/SlnFileWithNoProjectReferencesAndFSharpProject/FSharpProject/FSharpProject.fsproj
+++ b/TestAssets/TestProjects/SlnFileWithNoProjectReferencesAndFSharpProject/FSharpProject/FSharpProject.fsproj
@@ -1,81 +1,12 @@
-
-
-
+
+
- Debug
- AnyCPU
- 2.0
- 52161bb2-18bf-4304-87e7-8d7f0c98ccf3
Exe
- FSharpProject
- FSharpProject
- v4.5.2
- true
- 4.4.1.0
- FSharpProject
+ netcoreapp2.1
-
- true
- full
- false
- false
- bin\$(Configuration)\
- DEBUG;TRACE
- 3
- AnyCPU
- bin\$(Configuration)\$(AssemblyName).XML
- true
-
-
- pdbonly
- true
- true
- bin\$(Configuration)\
- TRACE
- 3
- AnyCPU
- bin\$(Configuration)\$(AssemblyName).XML
- true
-
-
- 11
-
-
-
-
- $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets
-
-
-
-
- $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets
-
-
-
-
+
-
-
-
-
-
-
- True
-
-
-
-
-
- ..\packages\System.ValueTuple.4.0.0-rc3-24212-01\lib\netstandard1.1\System.ValueTuple.dll
-
-
-
-
+
+
\ No newline at end of file
diff --git a/TestAssets/TestProjects/SlnFileWithNoProjectReferencesAndFSharpProject/FSharpProject/packages.config b/TestAssets/TestProjects/SlnFileWithNoProjectReferencesAndFSharpProject/FSharpProject/packages.config
deleted file mode 100644
index 2688d2baf..000000000
--- a/TestAssets/TestProjects/SlnFileWithNoProjectReferencesAndFSharpProject/FSharpProject/packages.config
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/TestAssets/TestProjects/SlnFileWithNoProjectReferencesAndUnknownProjectType/App.sln b/TestAssets/TestProjects/SlnFileWithNoProjectReferencesAndUnknownProjectType/App.sln
new file mode 100644
index 000000000..5b61df887
--- /dev/null
+++ b/TestAssets/TestProjects/SlnFileWithNoProjectReferencesAndUnknownProjectType/App.sln
@@ -0,0 +1,18 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.26006.2
+MinimumVisualStudioVersion = 10.0.40219.1
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|Any CPU = Release|Any CPU
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/TestAssets/TestProjects/SlnFileWithNoProjectReferencesAndUnknownProjectType/UnknownProject/UnknownProject.unknownproj b/TestAssets/TestProjects/SlnFileWithNoProjectReferencesAndUnknownProjectType/UnknownProject/UnknownProject.unknownproj
new file mode 100644
index 000000000..2ed799e9d
--- /dev/null
+++ b/TestAssets/TestProjects/SlnFileWithNoProjectReferencesAndUnknownProjectType/UnknownProject/UnknownProject.unknownproj
@@ -0,0 +1,3 @@
+
+
+
diff --git a/TestAssets/TestProjects/SlnFileWithNoProjectReferencesAndUnknownProjectWithMultipleProjectTypeGuids/UnknownProject/UnknownProject.unknownproj b/TestAssets/TestProjects/SlnFileWithNoProjectReferencesAndUnknownProjectWithMultipleProjectTypeGuids/UnknownProject/UnknownProject.unknownproj
index c5e694360..e5a55313b 100644
--- a/TestAssets/TestProjects/SlnFileWithNoProjectReferencesAndUnknownProjectWithMultipleProjectTypeGuids/UnknownProject/UnknownProject.unknownproj
+++ b/TestAssets/TestProjects/SlnFileWithNoProjectReferencesAndUnknownProjectWithMultipleProjectTypeGuids/UnknownProject/UnknownProject.unknownproj
@@ -1,6 +1,6 @@
- {20E2F8CC-55AA-4705-B10F-7ABA6F107ECE};{130159A9-F047-44B3-88CF-0CF7F02ED50F}
+ {20E2F8CC-55AA-4705-B10F-7ABA6F107ECE};{130159A9-F047-44B3-88CF-0CF7F02ED50F}
diff --git a/TestAssets/TestProjects/SlnFileWithNoProjectReferencesAndUnknownProjectWithSingleProjectTypeGuid/UnknownProject/UnknownProject.unknownproj b/TestAssets/TestProjects/SlnFileWithNoProjectReferencesAndUnknownProjectWithSingleProjectTypeGuid/UnknownProject/UnknownProject.unknownproj
index 2615598f1..44f4622a0 100644
--- a/TestAssets/TestProjects/SlnFileWithNoProjectReferencesAndUnknownProjectWithSingleProjectTypeGuid/UnknownProject/UnknownProject.unknownproj
+++ b/TestAssets/TestProjects/SlnFileWithNoProjectReferencesAndUnknownProjectWithSingleProjectTypeGuid/UnknownProject/UnknownProject.unknownproj
@@ -1,6 +1,6 @@
- {130159A9-F047-44B3-88CF-0CF7F02ED50F}
+ {130159A9-F047-44B3-88CF-0CF7F02ED50F}
diff --git a/src/Microsoft.DotNet.Cli.Sln.Internal/ProjectTypeGuids.cs b/src/Microsoft.DotNet.Cli.Sln.Internal/ProjectTypeGuids.cs
index 547e93eef..63292ebf7 100644
--- a/src/Microsoft.DotNet.Cli.Sln.Internal/ProjectTypeGuids.cs
+++ b/src/Microsoft.DotNet.Cli.Sln.Internal/ProjectTypeGuids.cs
@@ -6,6 +6,8 @@ namespace Microsoft.DotNet.Cli.Sln.Internal
public static class ProjectTypeGuids
{
public const string CSharpProjectTypeGuid = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}";
+ public const string FSharpProjectTypeGuid = "{F2A71F9B-5D33-465A-A702-920D77279786}";
+ public const string VBProjectTypeGuid = "{F184B08F-C81C-45F6-A57F-5ABD9991F28F}";
public const string SolutionFolderGuid = "{2150E333-8FDC-42A3-9474-1A3956D46DE8}";
}
}
diff --git a/src/dotnet/CommonLocalizableStrings.resx b/src/dotnet/CommonLocalizableStrings.resx
index ad40ada4d..188643c16 100644
--- a/src/dotnet/CommonLocalizableStrings.resx
+++ b/src/dotnet/CommonLocalizableStrings.resx
@@ -118,7 +118,7 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- Unsupported project type. Please check with your sdk provider.
+ Project '{0}' has an unknown project type and cannot be added to the solution file. Please contact your SDK provider for support.
Project already has a reference to `{0}`.
diff --git a/src/dotnet/ProjectInstanceExtensions.cs b/src/dotnet/ProjectInstanceExtensions.cs
index fdfd41b38..457e83d82 100644
--- a/src/dotnet/ProjectInstanceExtensions.cs
+++ b/src/dotnet/ProjectInstanceExtensions.cs
@@ -20,31 +20,9 @@ namespace Microsoft.DotNet.Tools.Common
return projectGuid.ToString("B").ToUpper();
}
- public static string GetProjectTypeGuid(this ProjectInstance projectInstance)
+ public static string GetDefaultProjectTypeGuid(this ProjectInstance projectInstance)
{
- string projectTypeGuid = null;
-
- var projectTypeGuidProperty = projectInstance.GetPropertyValue("ProjectTypeGuid");
- if (!string.IsNullOrEmpty(projectTypeGuidProperty))
- {
- projectTypeGuid = projectTypeGuidProperty.Split(';').Last();
- }
- else
- {
- projectTypeGuid = projectInstance.GetPropertyValue("DefaultProjectTypeGuid");
- }
-
- if (string.IsNullOrEmpty(projectTypeGuid))
- {
- //ISSUE: https://github.com/dotnet/sdk/issues/522
- //The real behavior we want (once DefaultProjectTypeGuid support is in) is to throw
- //when we cannot find ProjectTypeGuid or DefaultProjectTypeGuid. But for now we
- //need to default to the C# one.
- //throw new GracefulException(CommonLocalizableStrings.UnsupportedProjectType);
- projectTypeGuid = ProjectTypeGuids.CSharpProjectTypeGuid;
- }
-
- return projectTypeGuid;
+ return projectInstance.GetPropertyValue("DefaultProjectTypeGuid");
}
public static IEnumerable GetPlatforms(this ProjectInstance projectInstance)
diff --git a/src/dotnet/ProjectRootElementExtensions.cs b/src/dotnet/ProjectRootElementExtensions.cs
new file mode 100644
index 000000000..1d7ae3a53
--- /dev/null
+++ b/src/dotnet/ProjectRootElementExtensions.cs
@@ -0,0 +1,23 @@
+// 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;
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.Build.Construction;
+
+namespace Microsoft.DotNet.Tools.Common
+{
+ public static class ProjectRootElementExtensions
+ {
+ public static string GetProjectTypeGuid(this ProjectRootElement rootElement)
+ {
+ return rootElement
+ .Properties
+ .FirstOrDefault(p => string.Equals(p.Name, "ProjectTypeGuids", StringComparison.OrdinalIgnoreCase))
+ ?.Value
+ .Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)
+ .LastOrDefault(g => !string.IsNullOrWhiteSpace(g));
+ }
+ }
+}
diff --git a/src/dotnet/SlnFileExtensions.cs b/src/dotnet/SlnFileExtensions.cs
index e1d91c224..292c697e4 100644
--- a/src/dotnet/SlnFileExtensions.cs
+++ b/src/dotnet/SlnFileExtensions.cs
@@ -37,10 +37,12 @@ namespace Microsoft.DotNet.Tools.Common
}
else
{
+ ProjectRootElement rootElement = null;
ProjectInstance projectInstance = null;
try
{
- projectInstance = new ProjectInstance(fullProjectPath);
+ rootElement = ProjectRootElement.Open(fullProjectPath);
+ projectInstance = new ProjectInstance(rootElement);
}
catch (InvalidProjectFileException e)
{
@@ -54,11 +56,20 @@ namespace Microsoft.DotNet.Tools.Common
var slnProject = new SlnProject
{
Id = projectInstance.GetProjectId(),
- TypeGuid = projectInstance.GetProjectTypeGuid(),
+ TypeGuid = rootElement.GetProjectTypeGuid() ?? projectInstance.GetDefaultProjectTypeGuid(),
Name = Path.GetFileNameWithoutExtension(relativeProjectPath),
FilePath = relativeProjectPath
};
+ if (string.IsNullOrEmpty(slnProject.TypeGuid))
+ {
+ Reporter.Error.WriteLine(
+ string.Format(
+ CommonLocalizableStrings.UnsupportedProjectType,
+ projectInstance.FullPath));
+ return;
+ }
+
// NOTE: The order you create the sections determines the order they are written to the sln
// file. In the case of an empty sln file, in order to make sure the solution configurations
// section comes first we need to add it first. This doesn't affect correctness but does
diff --git a/src/dotnet/xlf/CommonLocalizableStrings.cs.xlf b/src/dotnet/xlf/CommonLocalizableStrings.cs.xlf
index f464118ce..03639a1a6 100644
--- a/src/dotnet/xlf/CommonLocalizableStrings.cs.xlf
+++ b/src/dotnet/xlf/CommonLocalizableStrings.cs.xlf
@@ -600,8 +600,8 @@
-
- Nepodporovaný typ projektu. Ověřte to prosím u poskytovatele sady SDK.
+
+ Nepodporovaný typ projektu. Ověřte to prosím u poskytovatele sady SDK.
diff --git a/src/dotnet/xlf/CommonLocalizableStrings.de.xlf b/src/dotnet/xlf/CommonLocalizableStrings.de.xlf
index cae4ffe72..528a1f198 100644
--- a/src/dotnet/xlf/CommonLocalizableStrings.de.xlf
+++ b/src/dotnet/xlf/CommonLocalizableStrings.de.xlf
@@ -600,8 +600,8 @@
-
- Nicht unterstützter Projekttyp. Wenden Sie sich an Ihren SDK-Anbieter.
+
+ Nicht unterstützter Projekttyp. Wenden Sie sich an Ihren SDK-Anbieter.
diff --git a/src/dotnet/xlf/CommonLocalizableStrings.es.xlf b/src/dotnet/xlf/CommonLocalizableStrings.es.xlf
index 55e770628..9d8bbcb26 100644
--- a/src/dotnet/xlf/CommonLocalizableStrings.es.xlf
+++ b/src/dotnet/xlf/CommonLocalizableStrings.es.xlf
@@ -600,8 +600,8 @@
-
- Tipo de proyecto no admitido. Consulte a su proveedor de SDK.
+
+ Tipo de proyecto no admitido. Consulte a su proveedor de SDK.
diff --git a/src/dotnet/xlf/CommonLocalizableStrings.fr.xlf b/src/dotnet/xlf/CommonLocalizableStrings.fr.xlf
index 5d7e2755f..ee89238f2 100644
--- a/src/dotnet/xlf/CommonLocalizableStrings.fr.xlf
+++ b/src/dotnet/xlf/CommonLocalizableStrings.fr.xlf
@@ -600,8 +600,8 @@
-
- Type de projet non pris en charge. Consultez le fournisseur de votre SDK.
+
+ Type de projet non pris en charge. Consultez le fournisseur de votre SDK.
diff --git a/src/dotnet/xlf/CommonLocalizableStrings.it.xlf b/src/dotnet/xlf/CommonLocalizableStrings.it.xlf
index 28d31da38..274e11230 100644
--- a/src/dotnet/xlf/CommonLocalizableStrings.it.xlf
+++ b/src/dotnet/xlf/CommonLocalizableStrings.it.xlf
@@ -600,8 +600,8 @@
-
- Tipo di progetto non supportato. Verificare con il provider SDK.
+
+ Tipo di progetto non supportato. Verificare con il provider SDK.
diff --git a/src/dotnet/xlf/CommonLocalizableStrings.ja.xlf b/src/dotnet/xlf/CommonLocalizableStrings.ja.xlf
index 46d5302b0..d0fefd2b5 100644
--- a/src/dotnet/xlf/CommonLocalizableStrings.ja.xlf
+++ b/src/dotnet/xlf/CommonLocalizableStrings.ja.xlf
@@ -600,8 +600,8 @@
-
- サポートされていないプロジェクトの種類です。SDK プロバイダーに確認してください。
+
+ サポートされていないプロジェクトの種類です。SDK プロバイダーに確認してください。
diff --git a/src/dotnet/xlf/CommonLocalizableStrings.ko.xlf b/src/dotnet/xlf/CommonLocalizableStrings.ko.xlf
index 470eb0bc5..e5716a3a0 100644
--- a/src/dotnet/xlf/CommonLocalizableStrings.ko.xlf
+++ b/src/dotnet/xlf/CommonLocalizableStrings.ko.xlf
@@ -600,8 +600,8 @@
-
- 지원되지 않는 프로젝트 형식입니다. SDK 공급자를 확인하세요.
+
+ 지원되지 않는 프로젝트 형식입니다. SDK 공급자를 확인하세요.
diff --git a/src/dotnet/xlf/CommonLocalizableStrings.pl.xlf b/src/dotnet/xlf/CommonLocalizableStrings.pl.xlf
index 889ec7173..d31152f29 100644
--- a/src/dotnet/xlf/CommonLocalizableStrings.pl.xlf
+++ b/src/dotnet/xlf/CommonLocalizableStrings.pl.xlf
@@ -600,8 +600,8 @@
-
- Nieobsługiwany typ projektu. Skontaktuj się z dostawcą zestawu SDK.
+
+ Nieobsługiwany typ projektu. Skontaktuj się z dostawcą zestawu SDK.
diff --git a/src/dotnet/xlf/CommonLocalizableStrings.pt-BR.xlf b/src/dotnet/xlf/CommonLocalizableStrings.pt-BR.xlf
index 7d9b411ff..a4326cfcb 100644
--- a/src/dotnet/xlf/CommonLocalizableStrings.pt-BR.xlf
+++ b/src/dotnet/xlf/CommonLocalizableStrings.pt-BR.xlf
@@ -600,8 +600,8 @@
-
- Tipo de projeto sem suporte. Verifique com seu provedor de SDK.
+
+ Tipo de projeto sem suporte. Verifique com seu provedor de SDK.
diff --git a/src/dotnet/xlf/CommonLocalizableStrings.ru.xlf b/src/dotnet/xlf/CommonLocalizableStrings.ru.xlf
index 7ecf75ccc..7318ecbde 100644
--- a/src/dotnet/xlf/CommonLocalizableStrings.ru.xlf
+++ b/src/dotnet/xlf/CommonLocalizableStrings.ru.xlf
@@ -600,8 +600,8 @@
-
- Тип проекта не поддерживается. Обратитесь к поставщику пакета SDK.
+
+ Тип проекта не поддерживается. Обратитесь к поставщику пакета SDK.
diff --git a/src/dotnet/xlf/CommonLocalizableStrings.tr.xlf b/src/dotnet/xlf/CommonLocalizableStrings.tr.xlf
index b633fd9cd..b128725bd 100644
--- a/src/dotnet/xlf/CommonLocalizableStrings.tr.xlf
+++ b/src/dotnet/xlf/CommonLocalizableStrings.tr.xlf
@@ -600,8 +600,8 @@
-
- Proje türü desteklenmiyor. Lütfen SDK sağlayıcınıza başvurun.
+
+ Proje türü desteklenmiyor. Lütfen SDK sağlayıcınıza başvurun.
diff --git a/src/dotnet/xlf/CommonLocalizableStrings.zh-Hans.xlf b/src/dotnet/xlf/CommonLocalizableStrings.zh-Hans.xlf
index 11fef08ba..f33533c58 100644
--- a/src/dotnet/xlf/CommonLocalizableStrings.zh-Hans.xlf
+++ b/src/dotnet/xlf/CommonLocalizableStrings.zh-Hans.xlf
@@ -600,8 +600,8 @@
-
- 不支持的项目类型。请联系 SDK 提供商。
+
+ 不支持的项目类型。请联系 SDK 提供商。
diff --git a/src/dotnet/xlf/CommonLocalizableStrings.zh-Hant.xlf b/src/dotnet/xlf/CommonLocalizableStrings.zh-Hant.xlf
index 413d99070..416b821ff 100644
--- a/src/dotnet/xlf/CommonLocalizableStrings.zh-Hant.xlf
+++ b/src/dotnet/xlf/CommonLocalizableStrings.zh-Hant.xlf
@@ -600,8 +600,8 @@
-
- 不支援的專案類型。請與 SDK 提供者連絡。
+
+ 不支援的專案類型。請與 SDK 提供者連絡。
diff --git a/test/dotnet-migrate.Tests/GivenThatIWantToMigrateSolutions.cs b/test/dotnet-migrate.Tests/GivenThatIWantToMigrateSolutions.cs
index af96bd2a2..585a3da02 100644
--- a/test/dotnet-migrate.Tests/GivenThatIWantToMigrateSolutions.cs
+++ b/test/dotnet-migrate.Tests/GivenThatIWantToMigrateSolutions.cs
@@ -64,9 +64,7 @@ namespace Microsoft.DotNet.Migration.Tests
slnProject.FilePath.Should().Be(Path.Combine("..", "TestLibrary", "TestLibrary.csproj"));
slnProject = nonSolutionFolderProjects.Where((p) => p.Name == "subdir").Single();
- //ISSUE: https://github.com/dotnet/sdk/issues/522
- //Once we have that change migrate will always burn in the C# guid
- //slnProject.TypeGuid.Should().Be(ProjectTypeGuids.CSharpProjectTypeGuid);
+ slnProject.TypeGuid.Should().Be(ProjectTypeGuids.CSharpProjectTypeGuid);
slnProject.FilePath.Should().Be(Path.Combine("src", "subdir", "subdir.csproj"));
}
}
diff --git a/test/dotnet-sln-add.Tests/GivenDotnetSlnAdd.cs b/test/dotnet-sln-add.Tests/GivenDotnetSlnAdd.cs
index bb50d5f5d..40f53d567 100644
--- a/test/dotnet-sln-add.Tests/GivenDotnetSlnAdd.cs
+++ b/test/dotnet-sln-add.Tests/GivenDotnetSlnAdd.cs
@@ -867,10 +867,9 @@ EndGlobal
}
[Theory]
- //ISSUE: https://github.com/dotnet/sdk/issues/522
- //[InlineData("SlnFileWithNoProjectReferencesAndCSharpProject", "CSharpProject", "CSharpProject.csproj", ProjectTypeGuids.CSharpProjectTypeGuid)]
- //[InlineData("SlnFileWithNoProjectReferencesAndFSharpProject", "FSharpProject", "FSharpProject.fsproj", "{F2A71F9B-5D33-465A-A702-920D77279786}")]
- //[InlineData("SlnFileWithNoProjectReferencesAndVBProject", "VBProject", "VBProject.vbproj", "{F184B08F-C81C-45F6-A57F-5ABD9991F28F}")]
+ [InlineData("SlnFileWithNoProjectReferencesAndCSharpProject", "CSharpProject", "CSharpProject.csproj", ProjectTypeGuids.CSharpProjectTypeGuid)]
+ [InlineData("SlnFileWithNoProjectReferencesAndFSharpProject", "FSharpProject", "FSharpProject.fsproj", ProjectTypeGuids.FSharpProjectTypeGuid)]
+ [InlineData("SlnFileWithNoProjectReferencesAndVBProject", "VBProject", "VBProject.vbproj", ProjectTypeGuids.VBProjectTypeGuid)]
[InlineData("SlnFileWithNoProjectReferencesAndUnknownProjectWithSingleProjectTypeGuid", "UnknownProject", "UnknownProject.unknownproj", "{130159A9-F047-44B3-88CF-0CF7F02ED50F}")]
[InlineData("SlnFileWithNoProjectReferencesAndUnknownProjectWithMultipleProjectTypeGuids", "UnknownProject", "UnknownProject.unknownproj", "{130159A9-F047-44B3-88CF-0CF7F02ED50F}")]
public void WhenPassedAProjectItAddsCorrectProjectTypeGuid(
@@ -891,8 +890,8 @@ EndGlobal
.WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput($"sln App.sln add {projectToAdd}");
cmd.Should().Pass();
- cmd.StdOut.Should().Be(string.Format(CommonLocalizableStrings.ProjectAddedToTheSolution, projectToAdd));
cmd.StdErr.Should().BeEmpty();
+ cmd.StdOut.Should().Be(string.Format(CommonLocalizableStrings.ProjectAddedToTheSolution, projectToAdd));
var slnFile = SlnFile.Read(Path.Combine(projectDirectory, "App.sln"));
var nonSolutionFolderProjects = slnFile.Projects.Where(
@@ -901,6 +900,35 @@ EndGlobal
nonSolutionFolderProjects.Single().TypeGuid.Should().Be(expectedTypeGuid);
}
+ [Fact]
+ public void WhenPassedAProjectWithoutATypeGuidItErrors()
+ {
+ var solutionDirectory = TestAssets
+ .Get("SlnFileWithNoProjectReferencesAndUnknownProjectType")
+ .CreateInstance()
+ .WithSourceFiles()
+ .Root
+ .FullName;
+
+ var solutionPath = Path.Combine(solutionDirectory, "App.sln");
+ var contentBefore = File.ReadAllText(solutionPath);
+
+ var projectToAdd = Path.Combine("UnknownProject", "UnknownProject.unknownproj");
+ var cmd = new DotnetCommand()
+ .WithWorkingDirectory(solutionDirectory)
+ .ExecuteWithCapturedOutput($"sln add {projectToAdd}");
+ cmd.Should().Pass();
+ cmd.StdErr.Should().Be(
+ string.Format(
+ CommonLocalizableStrings.UnsupportedProjectType,
+ Path.Combine(solutionDirectory, projectToAdd)));
+ cmd.StdOut.Should().BeEmpty();
+
+ File.ReadAllText(solutionPath)
+ .Should()
+ .BeVisuallyEquivalentTo(contentBefore);
+ }
+
[Fact]
private void WhenSlnContainsSolutionFolderWithDifferentCasingItDoesNotCreateDuplicate()
{