Browse Source

Handle error when trying to create a C++ project on a machine without Windows SDK installed.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5944 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Daniel Grunwald 15 years ago
parent
commit
481864c82e
  1. 30
      src/AddIns/BackendBindings/CppBinding/CppBinding/Project/CppProject.cs

30
src/AddIns/BackendBindings/CppBinding/CppBinding/Project/CppProject.cs

@ -2,12 +2,13 @@ @@ -2,12 +2,13 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.Build.Construction;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Internal.Templates;
using ICSharpCode.SharpDevelop.Project;
using System.Diagnostics;
using Microsoft.Build.Construction;
using Microsoft.Build.Exceptions;
namespace ICSharpCode.CppBinding.Project
{
@ -16,10 +17,15 @@ namespace ICSharpCode.CppBinding.Project @@ -16,10 +17,15 @@ namespace ICSharpCode.CppBinding.Project
public CppProject(ProjectCreateInformation info)
: base(info)
{
AddImport(DefaultPropsFile, null);
AddImport(PropsFile, null);
AddImport(DefaultTargetsFile, null);
AddProjectConfigurationsItemGroup();
try {
AddImport(DefaultPropsFile, null);
AddImport(PropsFile, null);
AddImport(DefaultTargetsFile, null);
AddProjectConfigurationsItemGroup();
base.ReevaluateIfNecessary(); // provoke exception if import is invalid
} catch (InvalidProjectFileException ex) {
throw new ProjectLoadException("Please ensure that the Windows SDK is installed on your computer.\n\n" + ex.Message, ex);
}
}
public CppProject(ProjectLoadInformation info)
@ -60,7 +66,7 @@ namespace ICSharpCode.CppBinding.Project @@ -60,7 +66,7 @@ namespace ICSharpCode.CppBinding.Project
string outputPath = GetEvaluatedProperty("OutDir") ?? "";
if (!Path.IsPathRooted(outputPath))
return FileUtility.NormalizePath(Path.Combine(Path.Combine(Path.Combine(Directory, ".."), outputPath),
AssemblyName + GetExtension(OutputType)));
AssemblyName + GetExtension(OutputType)));
else
{
// this will be valid if there is an explicit OutDir property in vcxproj file.
@ -83,11 +89,11 @@ namespace ICSharpCode.CppBinding.Project @@ -83,11 +89,11 @@ namespace ICSharpCode.CppBinding.Project
string extension = Path.GetExtension(fileName).ToLower();
switch (extension)
{
case ".cpp": return ItemType.ClCompile;
case ".c": return ItemType.ClCompile;
case ".hpp": return ItemType.ClInclude;
case ".h": return ItemType.ClInclude;
case ".rc": return new ItemType(RESOURCE_COMPILE);
case ".cpp": return ItemType.ClCompile;
case ".c": return ItemType.ClCompile;
case ".hpp": return ItemType.ClInclude;
case ".h": return ItemType.ClInclude;
case ".rc": return new ItemType(RESOURCE_COMPILE);
}
return base.GetDefaultItemType(fileName);
}

Loading…
Cancel
Save