Browse Source

Add C++ backend binding to samples. There's no support for editing project options and no templates; it's just a minimalist sample on how to write backend bindings for non-MSBuild project formats.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@3126 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 17 years ago
parent
commit
6139a17a8b
  1. 31
      samples/CppBackendBinding/Configuration/AssemblyInfo.cs
  2. 44
      samples/CppBackendBinding/CppBackendBinding.addin
  3. 69
      samples/CppBackendBinding/CppBackendBinding.csproj
  4. 18
      samples/CppBackendBinding/CppBackendBinding.sln
  5. 36
      samples/CppBackendBinding/CppLanguageBinding.cs
  6. 287
      samples/CppBackendBinding/CppProject.cs
  7. 45
      samples/CppBackendBinding/FileGroup.cs
  8. 57
      samples/CppBackendBinding/FileItem.cs
  9. 1
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  10. 2
      src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskView.cs
  11. 1
      src/Main/Base/Project/Src/Project/Items/ItemType.cs
  12. 2
      src/Main/Base/Project/Src/Project/Items/ProjectItem.cs
  13. 12
      src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs
  14. 35
      src/Main/Base/Project/Src/Project/ProjectLoadException.cs
  15. 8
      src/Main/Base/Project/Src/Services/LanguageBinding/LanguageBindingService.cs
  16. 55
      src/Main/Core/Project/Src/Services/FileUtility/FileUtility.cs

31
samples/CppBackendBinding/Configuration/AssemblyInfo.cs

@ -0,0 +1,31 @@ @@ -0,0 +1,31 @@
#region Using directives
using System;
using System.Reflection;
using System.Runtime.InteropServices;
#endregion
// 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.
[assembly: AssemblyTitle("C++ Backend Binding for SharpDevelop")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CppBackendBinding")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
[assembly: ComVisible(false)]
// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all the values or you can use the default the Revision and
// Build Numbers by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.*")]

44
samples/CppBackendBinding/CppBackendBinding.addin

@ -0,0 +1,44 @@ @@ -0,0 +1,44 @@
<AddIn name = "CppBackendBinding"
author = "Daniel Grunwald"
description = "An example AddIn demonstrating how to write a SharpDevelop backend binding for non-MSBuild projects">
<Runtime>
<Import assembly = "CppBackendBinding.dll"/>
</Runtime>
<Path name = "/SharpDevelop/Workbench/FileFilter">
<FileFilter id = "C++"
insertbefore="AllFiles"
name = "C++/C files"
extensions = "*.cpp;*.h;*.c;*.h;*.hpp"/>
</Path>
<Path name = "/SharpDevelop/Workbench/Combine/FileFilter">
<FileFilter id = "CppProject"
insertbefore="AllFiles"
name = "Visual C++ project files (*.vcproj)"
class = "ICSharpCode.SharpDevelop.Project.LoadProject"
extensions = "*.vcproj"/>
</Path>
<!--
SharpDevelop doesn't support creating non-MSBuild projects from templates
(though an addin could work around that by replacing the created MSBuild project with the correct
project format immediately after it was created)
<Path name = "/SharpDevelop/BackendBindings/Templates">
<Directory id = "ILAsm" path = "./Templates" />
</Path>
-->
<Path path = "/SharpDevelop/BackendBindings/ProjectOptions/C++">
<!-- TODO: project option panels -->
</Path>
<Path name = "/SharpDevelop/Workbench/LanguageBindings">
<LanguageBinding id = "C++"
guid = "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}"
supportedextensions = ".cpp;.c"
projectfileextension = ".vcproj"
class = "CppBackendBinding.CppLanguageBinding" />
</Path>
</AddIn>

69
samples/CppBackendBinding/CppBackendBinding.csproj

@ -0,0 +1,69 @@ @@ -0,0 +1,69 @@
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{F279DD27-21A9-4D69-AAE3-00DB403257CB}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<OutputType>Library</OutputType>
<RootNamespace>CppBackendBinding</RootNamespace>
<AssemblyName>CppBackendBinding</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<OutputPath>..\..\AddIns\Samples\CppBinding\</OutputPath>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType>
<Optimize>False</Optimize>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<DefineConstants>DEBUG;TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugSymbols>False</DebugSymbols>
<DebugType>None</DebugType>
<Optimize>True</Optimize>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<PlatformTarget>AnyCPU</PlatformTarget>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup>
<Reference Include="ICSharpCode.Core">
<HintPath>D:\SD\3.0\SharpDevelop\bin\ICSharpCode.Core.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="ICSharpCode.SharpDevelop">
<HintPath>D:\SD\3.0\SharpDevelop\bin\ICSharpCode.SharpDevelop.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="ICSharpCode.SharpDevelop.Dom">
<HintPath>D:\SD\3.0\SharpDevelop\bin\ICSharpCode.SharpDevelop.Dom.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<None Include="CppBackendBinding.addin">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<Compile Include="Configuration\AssemblyInfo.cs" />
<Compile Include="CppLanguageBinding.cs" />
<Compile Include="CppProject.cs" />
<Compile Include="FileGroup.cs" />
<Compile Include="FileItem.cs" />
</ItemGroup>
</Project>

18
samples/CppBackendBinding/CppBackendBinding.sln

@ -0,0 +1,18 @@ @@ -0,0 +1,18 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
# SharpDevelop 3.0.0.3075
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CppBackendBinding", "CppBackendBinding.csproj", "{F279DD27-21A9-4D69-AAE3-00DB403257CB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F279DD27-21A9-4D69-AAE3-00DB403257CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F279DD27-21A9-4D69-AAE3-00DB403257CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F279DD27-21A9-4D69-AAE3-00DB403257CB}.Release|Any CPU.Build.0 = Release|Any CPU
{F279DD27-21A9-4D69-AAE3-00DB403257CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
EndGlobalSection
EndGlobal

36
samples/CppBackendBinding/CppLanguageBinding.cs

@ -0,0 +1,36 @@ @@ -0,0 +1,36 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision$</version>
// </file>
using System;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Internal.Templates;
using ICSharpCode.SharpDevelop.Project;
using System.IO;
namespace CppBackendBinding
{
public class CppLanguageBinding : ILanguageBinding
{
public const string LanguageName = "C++";
public string Language {
get {
return LanguageName;
}
}
public IProject LoadProject(IMSBuildEngineProvider provider, string fileName, string projectName)
{
return new CppProject(fileName, projectName);
}
public IProject CreateProject(ProjectCreateInformation info)
{
throw new NotImplementedException();
}
}
}

287
samples/CppBackendBinding/CppProject.cs

@ -0,0 +1,287 @@ @@ -0,0 +1,287 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <author name="Daniel Grunwald"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Xml;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Project;
namespace CppBackendBinding
{
/// <summary>
/// C++ project class. Handlings project loading and saving.
/// </summary>
public class CppProject : AbstractProject, IProjectItemListProvider, IProjectAllowChangeConfigurations
{
XmlDocument document = new XmlDocument();
List<FileGroup> groups = new List<FileGroup>();
List<FileItem> items = new List<FileItem>();
/// <summary>
/// Create a new C++ project that loads the specified .vcproj file.
/// </summary>
public CppProject(string fileName, string projectName)
{
this.Name = projectName;
this.FileName = fileName;
this.TypeGuid = "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}";
using (StreamReader r = new StreamReader(fileName, Encoding.Default)) {
try {
document.Load(r);
} catch (Exception ex) {
throw new ProjectLoadException(ex.Message, ex);
}
}
if (document.DocumentElement.Name != "VisualStudioProject")
throw new ProjectLoadException("The project is not a visual studio project.");
XmlElement filesElement = document.DocumentElement["Files"];
if (filesElement != null) {
foreach (XmlElement filterElement in filesElement.ChildNodes.OfType<XmlElement>()) {
if (filterElement.Name == "Filter") {
FileGroup group = new FileGroup(this, filterElement);
groups.Add(group);
foreach (XmlElement fileElement in filterElement.ChildNodes.OfType<XmlElement>()) {
if (fileElement.Name == "File" && fileElement.HasAttribute("RelativePath")) {
items.Add(new FileItem(group, fileElement));
}
}
}
}
}
}
public override string Language {
get { return CppLanguageBinding.LanguageName; }
}
public override void Save(string fileName)
{
lock (SyncRoot) {
// file item types may have changed, so remove all items from their parent elements
// and re-add them to the correct Filter elements
foreach (FileItem item in items) {
item.SaveChanges();
if (item.XmlElement.ParentNode != null)
item.XmlElement.ParentNode.RemoveChild(item.XmlElement);
}
foreach (FileItem item in items) {
FileGroup group = groups.Find(fg => fg.ItemType == item.ProjectItem.ItemType);
if (groups != null) {
group.XmlElement.AppendChild(item.XmlElement);
} else {
LoggingService.Warn("Couldn't find filter for item type " + item.ProjectItem.ItemType + ", the item was not saved!");
}
}
document.Save(fileName);
}
}
/// <summary>
/// Gets the list of available file item types. This member is thread-safe.
/// </summary>
public override ICollection<ItemType> AvailableFileItemTypes {
get {
lock (SyncRoot) {
return groups.ConvertAll(fg => fg.ItemType).AsReadOnly();
}
}
}
/// <summary>
/// Gets the list of items in the project. This member is thread-safe.
/// The returned collection is guaranteed not to change - adding new items or removing existing items
/// will create a new collection.
/// </summary>
public override ReadOnlyCollection<ProjectItem> Items {
get {
lock (SyncRoot) {
return new ReadOnlyCollection<ProjectItem>(items.ConvertAll(fi => fi.ProjectItem));
}
}
}
#region IProjectAllowChangeConfigurations
// TODO: Configuration/Platform handling
bool IProjectAllowChangeConfigurations.RenameProjectConfiguration(string oldName, string newName)
{
throw new NotImplementedException();
}
bool IProjectAllowChangeConfigurations.RenameProjectPlatform(string oldName, string newName)
{
throw new NotImplementedException();
}
bool IProjectAllowChangeConfigurations.AddProjectConfiguration(string newName, string copyFrom)
{
throw new NotImplementedException();
}
bool IProjectAllowChangeConfigurations.AddProjectPlatform(string newName, string copyFrom)
{
throw new NotImplementedException();
}
bool IProjectAllowChangeConfigurations.RemoveProjectConfiguration(string name)
{
throw new NotImplementedException();
}
bool IProjectAllowChangeConfigurations.RemoveProjectPlatform(string name)
{
throw new NotImplementedException();
}
#endregion
#region IProjectItemListProvider
void IProjectItemListProvider.AddProjectItem(ProjectItem item)
{
if (item == null)
throw new ArgumentNullException("item");
lock (SyncRoot) {
if (items.Exists(fi => fi.ProjectItem == item))
throw new ArgumentException("Project item already exists in project!");
items.Add(new FileItem(document, item));
}
}
bool IProjectItemListProvider.RemoveProjectItem(ProjectItem item)
{
lock (SyncRoot) {
return items.RemoveAll(fi => fi.ProjectItem == item) > 0;
}
}
#endregion
public override void StartBuild(ProjectBuildOptions options, IBuildFeedbackSink feedbackSink)
{
string commonTools = Environment.GetEnvironmentVariable("VS90COMNTOOLS");
if (string.IsNullOrEmpty(commonTools)) {
commonTools = Environment.GetEnvironmentVariable("VS80COMNTOOLS");
}
if (!string.IsNullOrEmpty(commonTools)) {
commonTools = Path.Combine(commonTools, "vsvars32.bat");
if (!File.Exists(commonTools))
commonTools = null;
}
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.Arguments = "/C";
if (commonTools != null) {
p.StartInfo.Arguments += " call \"" + commonTools + "\" &&";
}
p.StartInfo.Arguments += " vcbuild";
if (options.Target == BuildTarget.Build) {
// OK
} else if (options.Target == BuildTarget.Clean) {
p.StartInfo.Arguments += " /clean";
} else if (options.Target == BuildTarget.Rebuild) {
p.StartInfo.Arguments += " /rebuild";
}
p.StartInfo.Arguments += " /showenv";
p.StartInfo.Arguments += " \"" + this.FileName + "\"";
p.StartInfo.Arguments += " \"/error:Error: \"";
p.StartInfo.Arguments += " \"/warning:Warning: \"";
p.StartInfo.WorkingDirectory = this.Directory;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.EnvironmentVariables["VCBUILD_DEFAULT_CFG"] = options.Configuration + "|" + options.Platform;
p.EnableRaisingEvents = true;
p.OutputDataReceived += delegate(object sender, DataReceivedEventArgs e) {
if (!string.IsNullOrEmpty(e.Data)) {
BuildError error = ParseError(e.Data);
if (error != null)
feedbackSink.ReportError(error);
else
feedbackSink.ReportMessage(e.Data);
}
};
p.ErrorDataReceived += delegate(object sender, DataReceivedEventArgs e) {
if (!string.IsNullOrEmpty(e.Data)) {
BuildError error = ParseError(e.Data);
if (error != null)
feedbackSink.ReportError(error);
else
feedbackSink.ReportError(new BuildError(null, e.Data));
}
};
p.Exited += delegate(object sender, EventArgs e) {
p.CancelErrorRead();
p.CancelOutputRead();
feedbackSink.Done(p.ExitCode == 0);
p.Dispose();
};
feedbackSink.ReportMessage("Building " + this.Name);
feedbackSink.ReportMessage(p.StartInfo.FileName + " " + p.StartInfo.Arguments);
p.Start();
p.BeginOutputReadLine();
p.BeginErrorReadLine();
}
static readonly Regex errorRegex = new Regex(@"^Error: " +
@"([^(:]+?)" + // group 1: file name
@"(?:\((\d+)\))?" + // group 2: line number
@"\s*:\s*" + // first separator
@"(?:error ([^:]+):)?" + // group 3: error code
@"\s*(.*)$" // group 4: error message
);
static readonly Regex warningRegex = new Regex(@"^(?:\d+\>)?Warning: " +
@"([^(:]+?)" + // group 1: file name
@"(?:\((\d+)\))?" + // group 2: line number
@"\s*:\s*" + // first separator
@"(?:warning ([^:]+):)?" + // group 3: error code
@"\s*(.*)$" // group 4: error message
);
/// <summary>
/// Parses an error or warning message and returns a BuildError object for it.
/// </summary>
BuildError ParseError(string text)
{
bool isWarning = false;
Match match = errorRegex.Match(text);
if (!match.Success) {
match = warningRegex.Match(text);
isWarning = true;
}
if (match.Success) {
int line = -1;
try {
if (match.Groups[2].Length > 0) {
line = int.Parse(match.Groups[2].Value);
}
} catch (FormatException) {
} catch (OverflowException) {
}
return new BuildError(Path.Combine(Directory, match.Groups[1].Value), line, 0,
match.Groups[3].Value, match.Groups[4].Value) {
IsWarning = isWarning
};
} else {
return null;
}
}
}
}

45
samples/CppBackendBinding/FileGroup.cs

@ -0,0 +1,45 @@ @@ -0,0 +1,45 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <author name="Daniel Grunwald"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Xml;
using ICSharpCode.SharpDevelop.Project;
namespace CppBackendBinding
{
/// <summary>
/// Represents a {Filter} element in the .vcproj file.
/// </summary>
sealed class FileGroup
{
public readonly CppProject Project;
public readonly ItemType ItemType;
public readonly string[] Extensions;
public readonly XmlElement XmlElement;
public FileGroup(CppProject project, XmlElement filterElement)
{
this.Project = project;
this.XmlElement = filterElement;
switch (filterElement.GetAttribute("UniqueIdentifier")) {
case "{4FC737F1-C7A5-4376-A066-2A32D752A2FF}":
ItemType = ItemType.Compile;
break;
case "{93995380-89BD-4b04-88EB-625FBE52EBFB}":
ItemType = ItemType.Header;
break;
case "{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}":
ItemType = ItemType.Resource;
break;
default:
ItemType = new ItemType(filterElement.GetAttribute("Name"));
break;
}
Extensions = filterElement.GetAttribute("Filter").Split(';');
}
}
}

57
samples/CppBackendBinding/FileItem.cs

@ -0,0 +1,57 @@ @@ -0,0 +1,57 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <author name="Daniel Grunwald"/>
// <version>$Revision$</version>
// </file>
using ICSharpCode.Core;
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Text;
using System.Xml;
using ICSharpCode.SharpDevelop.Project;
namespace CppBackendBinding
{
/// <summary>
/// Represents a {File} element in the .vcproj file.
/// </summary>
sealed class FileItem
{
public readonly ProjectItem ProjectItem;
public readonly XmlElement XmlElement;
/// <summary>
/// Loads a file item from XML.
/// </summary>
public FileItem(FileGroup group, XmlElement fileElement)
{
this.XmlElement = fileElement;
string relativePath = fileElement.GetAttribute("RelativePath");
if (relativePath.StartsWith(".\\")) {
// SharpDevelop doesn't like paths starting with ".\", so strip it away:
relativePath = relativePath.Substring(2);
}
this.ProjectItem = new FileProjectItem(group.Project, group.ItemType, relativePath);
}
/// <summary>
/// Creates a new file item.
/// </summary>
public FileItem(XmlDocument document, ProjectItem item)
{
this.ProjectItem = item;
this.XmlElement = document.CreateElement("File");
SaveChanges();
}
public void SaveChanges()
{
this.XmlElement.SetAttribute("RelativePath", this.ProjectItem.Include);
}
}
}

1
src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj

@ -124,6 +124,7 @@ @@ -124,6 +124,7 @@
<Compile Include="Src\Project\ContextSpecificProperties.cs" />
<Compile Include="Src\Project\IBuildFeedbackSink.cs" />
<Compile Include="Src\Project\MSBuildFileProject.cs" />
<Compile Include="Src\Project\ProjectLoadException.cs" />
<Compile Include="Src\Project\ProjectPropertyChangedEventArgs.cs" />
<Compile Include="Src\Services\Debugger\BreakpointBookmark.cs" />
<Compile Include="Src\Services\Debugger\BreakpointBookmarkEventArgs.cs" />

2
src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskView.cs

@ -306,6 +306,8 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -306,6 +306,8 @@ namespace ICSharpCode.SharpDevelop.Gui
/// <returns>A formatted task list description.</returns>
string FormatDescription(string description)
{
if (string.IsNullOrEmpty(description))
return string.Empty;
string FormattedDescription = description.Replace("\r", " ");
FormattedDescription = FormattedDescription.Replace("\t", " ");
return FormattedDescription.Replace("\n", " ");

1
src/Main/Base/Project/Src/Project/Items/ItemType.cs

@ -36,6 +36,7 @@ namespace ICSharpCode.SharpDevelop.Project @@ -36,6 +36,7 @@ namespace ICSharpCode.SharpDevelop.Project
public static readonly ItemType ApplicationDefinition = new ItemType("ApplicationDefinition");
public static readonly ItemType Page = new ItemType("Page");
public static readonly ItemType BootstrapperFile = new ItemType("BootstrapperFile");
public static readonly ItemType Header = new ItemType("Header");
/// <summary>
/// Gets a collection of item types that are used for files.

2
src/Main/Base/Project/Src/Project/Items/ProjectItem.cs

@ -100,7 +100,7 @@ namespace ICSharpCode.SharpDevelop.Project @@ -100,7 +100,7 @@ namespace ICSharpCode.SharpDevelop.Project
/// Gets if the item is added to it's owner project.
/// </summary>
[Browsable(false)]
public bool IsAddedToProject {
internal bool IsAddedToProject {
get {
return buildItem != null;
}

12
src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs

@ -916,10 +916,16 @@ namespace ICSharpCode.SharpDevelop.Project @@ -916,10 +916,16 @@ namespace ICSharpCode.SharpDevelop.Project
// MSB4075 is:
// "The project file must be opened in VS IDE and converted to latest version
// before it can be build by MSBuild."
Converter.PrjxToSolutionProject.ConvertVSNetProject(fileName);
project.Load(fileName);
try {
Converter.PrjxToSolutionProject.ConvertVSNetProject(fileName);
project.Load(fileName);
} catch (System.Xml.XmlException ex2) {
throw new ProjectLoadException(ex2.Message, ex2);
} catch (MSBuild.InvalidProjectFileException ex2) {
throw new ProjectLoadException(ex2.Message, ex2);
}
} else {
throw;
throw new ProjectLoadException(ex.Message, ex);
}
}
this.ActiveConfiguration = GetEvaluatedProperty("Configuration") ?? this.ActiveConfiguration;

35
src/Main/Base/Project/Src/Project/ProjectLoadException.cs

@ -0,0 +1,35 @@ @@ -0,0 +1,35 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <author name="Daniel Grunwald"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Runtime.Serialization;
namespace ICSharpCode.SharpDevelop.Project
{
/// <summary>
/// Exception used when loading of a project fails.
/// </summary>
[Serializable()]
public class ProjectLoadException : Exception
{
public ProjectLoadException() : base()
{
}
public ProjectLoadException(string message) : base(message)
{
}
public ProjectLoadException(string message, Exception innerException) : base(message, innerException)
{
}
protected ProjectLoadException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
}

8
src/Main/Base/Project/Src/Services/LanguageBinding/LanguageBindingService.cs

@ -118,13 +118,7 @@ namespace ICSharpCode.SharpDevelop @@ -118,13 +118,7 @@ namespace ICSharpCode.SharpDevelop
location = FileUtility.NormalizePath(location);
try {
newProject = binding.LoadProject(provider, location, title);
} catch (XmlException ex) {
LoggingService.Warn("Project load error", ex);
if (progressMonitor != null) progressMonitor.ShowingDialog = true;
newProject = new UnknownProject(location, title, ex.Message, true);
newProject.TypeGuid = projectTypeGuid;
if (progressMonitor != null) progressMonitor.ShowingDialog = false;
} catch (Microsoft.Build.BuildEngine.InvalidProjectFileException ex) {
} catch (ProjectLoadException ex) {
LoggingService.Warn("Project load error", ex);
if (progressMonitor != null) progressMonitor.ShowingDialog = true;
newProject = new UnknownProject(location, title, ex.Message, true);

55
src/Main/Core/Project/Src/Services/FileUtility/FileUtility.cs

@ -85,36 +85,49 @@ namespace ICSharpCode.Core @@ -85,36 +85,49 @@ namespace ICSharpCode.Core
/// </summary>
public static string NetSdk20InstallRoot {
get {
if (netSdk20InstallRoot == null) {
if (netSdk20InstallRoot == null) {
netSdk20InstallRoot = GetPathFromRegistry(@"SOFTWARE\Microsoft\.NETFramework", "sdkInstallRootv2.0") ?? string.Empty;
}
return netSdk20InstallRoot;
}
}
static string netSdk30InstallRoot = null;
static string windowsSdk60InstallRoot = null;
/// <summary>
/// Location of the .NET 3.0 SDK (Windows SDK 6.0) install root.
/// </summary>
public static string NetSdk30InstallRoot {
public static string WindowsSdk60InstallRoot {
get {
if (netSdk30InstallRoot == null) {
netSdk30InstallRoot = GetPathFromRegistry(@"SOFTWARE\Microsoft\Microsoft SDKs\Windows\v6.0", "InstallationFolder") ?? string.Empty;
if (windowsSdk60InstallRoot == null) {
windowsSdk60InstallRoot = GetPathFromRegistry(@"SOFTWARE\Microsoft\Microsoft SDKs\Windows\v6.0", "InstallationFolder") ?? string.Empty;
}
return netSdk30InstallRoot;
return windowsSdk60InstallRoot;
}
}
static string netSdk35InstallRoot = null;
static string windowsSdk60aInstallRoot = null;
/// <summary>
/// Location of the .NET 3.5 SDK (Windows SDK 6.0a) install root.
/// Location of the Windows SDK Components in Visual Studio 2008 (.NET 3.5; Windows SDK 6.0a).
/// </summary>
public static string NetSdk35InstallRoot {
public static string WindowsSdk60aInstallRoot {
get {
if (netSdk35InstallRoot == null) {
netSdk35InstallRoot = GetPathFromRegistry(@"SOFTWARE\Microsoft\Microsoft SDKs\Windows\v6.0a", "InstallationFolder") ?? string.Empty;
if (windowsSdk60aInstallRoot == null) {
windowsSdk60aInstallRoot = GetPathFromRegistry(@"SOFTWARE\Microsoft\Microsoft SDKs\Windows\v6.0a", "InstallationFolder") ?? string.Empty;
}
return netSdk35InstallRoot;
return windowsSdk60aInstallRoot;
}
}
static string windowsSdk61InstallRoot = null;
/// <summary>
/// Location of the .NET 3.5 SDK (Windows SDK 6.1) install root.
/// </summary>
public static string WindowsSdk61InstallRoot {
get {
if (windowsSdk61InstallRoot == null) {
windowsSdk61InstallRoot = GetPathFromRegistry(@"SOFTWARE\Microsoft\Microsoft SDKs\Windows\v6.1", "InstallationFolder") ?? string.Empty;
}
return windowsSdk61InstallRoot;
}
}
@ -165,7 +178,7 @@ namespace ICSharpCode.Core @@ -165,7 +178,7 @@ namespace ICSharpCode.Core
}
/// <summary>
/// Searches all the .net sdk bin folders and return the path of the
/// Searches all the .net sdk bin folders and return the path of the
/// exe from the latest sdk.
/// </summary>
/// <param name="exeName">The EXE to search for.</param>
@ -175,16 +188,20 @@ namespace ICSharpCode.Core @@ -175,16 +188,20 @@ namespace ICSharpCode.Core
/// </exception>
public static string GetSdkPath(string exeName) {
string execPath;
if (Directory.Exists(NetSdk35InstallRoot)) {
execPath = Path.Combine(NetSdk35InstallRoot + @"\bin", exeName);
if (!string.IsNullOrEmpty(WindowsSdk61InstallRoot)) {
execPath = Path.Combine(WindowsSdk61InstallRoot, "bin\\" + exeName);
if (File.Exists(execPath)) { return execPath; }
}
if (!string.IsNullOrEmpty(WindowsSdk60aInstallRoot)) {
execPath = Path.Combine(WindowsSdk60aInstallRoot, "bin\\" + exeName);
if (File.Exists(execPath)) { return execPath; }
}
if (Directory.Exists(NetSdk30InstallRoot)) {
execPath = Path.Combine(NetSdk30InstallRoot + @"\bin", exeName);
if (!string.IsNullOrEmpty(WindowsSdk60InstallRoot)) {
execPath = Path.Combine(WindowsSdk60InstallRoot, "bin\\" + exeName);
if (File.Exists(execPath)) { return execPath; }
}
if (Directory.Exists(NetSdk20InstallRoot)) {
execPath = Path.Combine(NetSdk20InstallRoot + @"\bin", exeName);
if (!string.IsNullOrEmpty(NetSdk20InstallRoot)) {
execPath = Path.Combine(NetSdk20InstallRoot, "bin\\" + exeName);
if (File.Exists(execPath)) { return execPath; }
}
throw new FileNotFoundException(StringParser.Parse("${res:Fileutility.CantFindExecutableError}", new string[,] { {"EXECUTABLE", exeName} }));

Loading…
Cancel
Save