Skip to content

Commit

Permalink
v4.2.2 bug fixes and updates
Browse files Browse the repository at this point in the history
  • Loading branch information
pepone committed Mar 30, 2016
1 parent 7b6e2e3 commit a69815f
Show file tree
Hide file tree
Showing 20 changed files with 95 additions and 61 deletions.
2 changes: 1 addition & 1 deletion AddinRemoval/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
[assembly: AssemblyCompany("ZeroC, Inc.")]
[assembly: AssemblyProduct("Ice Visual Studio Extension")]
[assembly: AssemblyCopyright("Copyright (c) 2009-2016 ZeroC, Inc.")]
[assembly: AssemblyVersion("4.2.1")]
[assembly: AssemblyVersion("4.2.2")]
[assembly: AssemblyDelaySign(false)]
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## Changes in Ice Builder for Visual Studio 4.2.2

- Fixed an issue that could cause an COMException when accessing the project
GUID.

- Fixed an issue in saving C# project settings.

- Fixed an issue where setting the "Build Automatically" option introduced in
version 4.2.0 could result in a InvalidOperationException exception being
throw.

## Changes in Ice Builder for Visual Studio 4.2.1

- Fixed an issue that could cause a null pointer exception when
Expand Down
6 changes: 3 additions & 3 deletions IceBuilder/Builder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ public Builder(IVsBuildManagerAccessor2 accessor)

public bool Build(IVsProject p, BuildCallback buildCallback, BuildLogger buildLogger)
{
ProjectUtil.SaveProject(p);
MSBuildProject project = MSBuildUtils.LoadedProject(ProjectUtil.GetProjectFullPath(p), false);
MSBuildProject project = MSBuildUtils.LoadedProject(ProjectUtil.GetProjectFullPath(p), DTEUtil.IsCppProject(p), false);

//
// We need to set this before we acquire the build resources otherwise Msbuild
Expand Down Expand Up @@ -76,7 +75,8 @@ public bool Build(IVsProject p, BuildCallback buildCallback, BuildLogger buildLo
try
{
Dictionary<string, string> properties = new Dictionary<string, string>();
properties["Platform"] = buildCallback.SolutionConfiguration.PlatformName;
String platform = buildCallback.SolutionConfiguration.PlatformName;
properties["Platform"] = platform.Equals("Any CPU") ? "AnyCPU" : platform;
properties["Configuration"] = buildCallback.SolutionConfiguration.Name;

BuildRequestData buildRequest = new BuildRequestData(
Expand Down
27 changes: 14 additions & 13 deletions IceBuilder/CSharpConfigurationView.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions IceBuilder/CSharpConfigurationView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,5 +294,13 @@ private void ReferencedAssemblies_ItemChecked(object sender, System.Windows.Form
{
Dirty = true;
}

private void txtOutputDir_TextChanged(object sender, EventArgs e)
{
if (!txtOutputDir.Text.Equals(Page.Settings.OutputDir))
{
Dirty = true;
}
}
}
}
4 changes: 3 additions & 1 deletion IceBuilder/DTEUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@ public static IceBuilderProjectType IsIceBuilderEnabled(IVsProject project)
IsCSharpProject(project) ? IceBuilderProjectType.CsharpProjectType : IceBuilderProjectType.None;
if (type != IceBuilderProjectType.None)
{
if (MSBuildUtils.IsIceBuilderEnabled(MSBuildUtils.LoadedProject(ProjectUtil.GetProjectFullPath(project))))
if (MSBuildUtils.IsIceBuilderEnabled(MSBuildUtils.LoadedProject(ProjectUtil.GetProjectFullPath(project),
DTEUtil.IsCppProject(project),
true)))
{
return type;
}
Expand Down
5 changes: 2 additions & 3 deletions IceBuilder/DocumentEventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,9 @@ public int OnBeforeDocumentWindowShow(uint docCookie, int fFirstShow, IVsWindowF
}
}
}
catch (Exception ex)
catch (Exception)
{
Package.UnexpectedExceptionWarning(ex);
throw;
// Could happend with some document types
}
return 0;
}
Expand Down
23 changes: 10 additions & 13 deletions IceBuilder/MSBuildUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,34 +35,31 @@ class MSBuildUtils
"$(LOCALAPPDATA)\\ZeroC\\IceBuilder\\IceBuilder.CSharp.targets";


public static Microsoft.Build.Evaluation.Project LoadedProject(String path)
{
return LoadedProject(path, true);
}
static readonly ProjectCollection cppProjectColletion = new ProjectCollection();

public static Microsoft.Build.Evaluation.Project LoadedProject(String path, bool cached)
public static Microsoft.Build.Evaluation.Project LoadedProject(String path, bool cpp, bool cached)
{
Microsoft.Build.Evaluation.Project project = null;
ICollection<Microsoft.Build.Evaluation.Project> projects =
ProjectCollection.GlobalProjectCollection.GetLoadedProjects(path);
ProjectCollection collection = cpp ? cppProjectColletion : ProjectCollection.GlobalProjectCollection;
ICollection<Microsoft.Build.Evaluation.Project> projects = collection.GetLoadedProjects(path);


if (projects.Count == 0)
{
project = new Microsoft.Build.Evaluation.Project(path);
project = collection.LoadProject(path);
}
else
{
project = projects.First();
if(!cached)
if(cpp && !cached)
{
//
// That is required to get C++ project properties re-evaluated
// with Visual Studio 2013 and Visual Studio 2015
//
ProjectCollection.GlobalProjectCollection.UnloadProject(project);
ProjectCollection.GlobalProjectCollection.UnloadAllProjects();
project = ProjectCollection.GlobalProjectCollection.LoadProject(path);
collection.UnloadProject(project);
collection.UnloadAllProjects();
project = collection.LoadProject(path);
}
}
return project;
Expand Down Expand Up @@ -310,7 +307,7 @@ public static void SetIceHome(List<IVsProject> projects, String iceHome, String
{
if(DTEUtil.IsIceBuilderEnabled(p) != IceBuilderProjectType.None)
{
Microsoft.Build.Evaluation.Project project = MSBuildUtils.LoadedProject(ProjectUtil.GetProjectFullPath(p));
Microsoft.Build.Evaluation.Project project = MSBuildUtils.LoadedProject(ProjectUtil.GetProjectFullPath(p), DTEUtil.IsCppProject(p), true);
ResolvedImport import = project.Imports.FirstOrDefault(i => i.ImportedProject.FullPath.EndsWith("IceBuilder.Common.props"));

if (import.ImportedProject != null)
Expand Down
20 changes: 14 additions & 6 deletions IceBuilder/Package.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,13 @@ public void SetIceHome(String value)

Microsoft.Win32.Registry.SetValue(IceCSharpAssembleyKey, "", GetAssembliesDir(value),
Microsoft.Win32.RegistryValueKind.String);

ICollection<Microsoft.Build.Evaluation.Project> projects =
Microsoft.Build.Evaluation.ProjectCollection.GlobalProjectCollection.GetLoadedProjects(props);
if(projects.Count > 0)
{
Microsoft.Build.Evaluation.ProjectCollection.GlobalProjectCollection.UnloadProject(p);
}
}
else
{
Expand Down Expand Up @@ -346,6 +353,7 @@ public void BuildNextProject()
else if (!Building && BuildingProject == null)
{
IVsProject p = _buildProjects.ElementAt(0);
ProjectUtil.SaveProject(p);
ProjectUtil.SetupGenerated(p, DTEUtil.IsIceBuilderEnabled(p));
if (BuildProject(p))
{
Expand Down Expand Up @@ -380,10 +388,9 @@ public void InitializeProjects(List<IVsProject> upgradeProjects)

if (projectType != IceBuilderProjectType.None)
{
EnvDTE.Project p = DTEUtil.GetProject(project as IVsHierarchy);
if (projectType == IceBuilderProjectType.CppProjectType)
{
VCUtil.SetupSliceFilter(p);
VCUtil.SetupSliceFilter(DTEUtil.GetProject(project as IVsHierarchy));
}
if (AutoBuilding)
{
Expand Down Expand Up @@ -839,7 +846,8 @@ private void addIceBuilder_BeforeQueryStatus(object sender, EventArgs e)
{
if(DTEUtil.IsCppProject(p) || DTEUtil.IsCSharpProject(p))
{
command.Enabled = !MSBuildUtils.IsIceBuilderEnabled(MSBuildUtils.LoadedProject(ProjectUtil.GetProjectFullPath(p)));
command.Enabled = !MSBuildUtils.IsIceBuilderEnabled(MSBuildUtils.LoadedProject(
ProjectUtil.GetProjectFullPath(p), DTEUtil.IsCppProject(p), true));
}
else
{
Expand Down Expand Up @@ -867,7 +875,7 @@ private void removeIceBuilder_BeforeQueryStatus(object sender, EventArgs e)
{
if (DTEUtil.IsCppProject(p) || DTEUtil.IsCSharpProject(p))
{
command.Enabled = MSBuildUtils.IsIceBuilderEnabled(MSBuildUtils.LoadedProject(ProjectUtil.GetProjectFullPath(p)));
command.Enabled = MSBuildUtils.IsIceBuilderEnabled(MSBuildUtils.LoadedProject(ProjectUtil.GetProjectFullPath(p), DTEUtil.IsCppProject(p), true));
}
else
{
Expand Down Expand Up @@ -906,7 +914,7 @@ private void AddIceBuilderToProject(object sender, EventArgs e)

public void AddIceBuilderToProject(IVsProject p)
{
Microsoft.Build.Evaluation.Project project = MSBuildUtils.LoadedProject(ProjectUtil.GetProjectFullPath(p));
Microsoft.Build.Evaluation.Project project = MSBuildUtils.LoadedProject(ProjectUtil.GetProjectFullPath(p), DTEUtil.IsCppProject(p), true);
if (MSBuildUtils.AddIceBuilderToProject(project))
{
if (DTEUtil.IsCppProject(p))
Expand Down Expand Up @@ -969,7 +977,7 @@ private void RemoveIceBuilderFromProject(object sender, EventArgs e)
private void RemoveIceBuilderFromProject(IVsProject p)
{
String path = ProjectUtil.GetProjectFullPath(p);
Microsoft.Build.Evaluation.Project project = MSBuildUtils.LoadedProject(path);
Microsoft.Build.Evaluation.Project project = MSBuildUtils.LoadedProject(path, DTEUtil.IsCppProject(p), true);
MSBuildUtils.RemoveIceBuilderFromProject(project);
foreach (IVsProject p1 in _buildProjects)
{
Expand Down
4 changes: 2 additions & 2 deletions IceBuilder/ProjectConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ public static void TryUpgrade(List<IVsProject> projects)
if(DTEUtil.IsCppProject(project) || DTEUtil.IsCSharpProject(project))
{
String fullName = ProjectUtil.GetProjectFullPath(project);
if(new OldConfiguration().Load(MSBuildUtils.LoadedProject(fullName), false))
if(new OldConfiguration().Load(MSBuildUtils.LoadedProject(fullName, DTEUtil.IsCppProject(project), true), false))
{
upgradeProjects.Add(FileUtil.RelativePath(baseDir, fullName), project);
}
Expand Down Expand Up @@ -338,7 +338,7 @@ public static void Upgrade(List<IVsProject> projects, UpgradeProgressCallback pr
public static bool Upgrade(IVsProject project)
{
OldConfiguration oldConfiguration = new OldConfiguration();
Microsoft.Build.Evaluation.Project msbuildProject = MSBuildUtils.LoadedProject(ProjectUtil.GetProjectFullPath(project));
Microsoft.Build.Evaluation.Project msbuildProject = MSBuildUtils.LoadedProject(ProjectUtil.GetProjectFullPath(project), DTEUtil.IsCppProject(project), true);

if (oldConfiguration.Load(msbuildProject, true))
{
Expand Down
28 changes: 18 additions & 10 deletions IceBuilder/ProjectUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,17 @@ public static Guid GetProjecTypeGuid(IVsProject project)
IVsHierarchy hierarchy = project as IVsHierarchy;
if(hierarchy != null)
{
Guid type;
ErrorHandler.ThrowOnFailure(hierarchy.GetGuidProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_TypeGuid, out type));
return type;
}
else
{
return new Guid();
try
{
Guid type;
ErrorHandler.ThrowOnFailure(hierarchy.GetGuidProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_TypeGuid, out type));
return type;
}
catch(Exception)
{
}
}
return new Guid();
}
public static void SaveProject(IVsProject project)
{
Expand Down Expand Up @@ -234,13 +237,13 @@ public static String GetProperty(IVsProject project, String name)

public static String GetProperty(IVsProject project, String name, String defaultValue)
{
String value = MSBuildUtils.GetProperty(MSBuildUtils.LoadedProject(GetProjectFullPath(project)), name);
String value = MSBuildUtils.GetProperty(MSBuildUtils.LoadedProject(GetProjectFullPath(project), DTEUtil.IsCppProject(project), true), name);
return String.IsNullOrEmpty(value) ? defaultValue : value;
}

public static void SetProperty(IVsProject project, String name, String value)
{
MSBuildUtils.SetProperty(MSBuildUtils.LoadedProject(GetProjectFullPath(project)), "IceBuilder", name, value);
MSBuildUtils.SetProperty(MSBuildUtils.LoadedProject(GetProjectFullPath(project), DTEUtil.IsCppProject(project), true), "IceBuilder", name, value);
}

public static String GetEvaluatedProperty(IVsProject project, String name)
Expand All @@ -250,7 +253,7 @@ public static String GetEvaluatedProperty(IVsProject project, String name)

public static String GetEvaluatedProperty(IVsProject project, String name, String defaultValue)
{
String value = MSBuildUtils.GetEvaluatedProperty(MSBuildUtils.LoadedProject(GetProjectFullPath(project)), name);
String value = MSBuildUtils.GetEvaluatedProperty(MSBuildUtils.LoadedProject(GetProjectFullPath(project), DTEUtil.IsCppProject(project), true), name);
return String.IsNullOrEmpty(value) ? defaultValue : value;
}

Expand Down Expand Up @@ -547,6 +550,11 @@ public static void SetupGenerated(IVsProject project, IceBuilderProjectType type
{
if(type == IceBuilderProjectType.CppProjectType)
{
//
// This will ensure that property reads don't use a cached project.
//
MSBuildUtils.LoadedProject(ProjectUtil.GetProjectFullPath(project), true, false);

List<CppGeneratedFileSet> generated = GetCppGeneratedFiles(project);
foreach(CppGeneratedFileSet fileset in generated)
{
Expand Down
2 changes: 1 addition & 1 deletion IceBuilder/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
[assembly: AssemblyCompany("ZeroC, Inc.")]
[assembly: AssemblyProduct("Ice Builder")]
[assembly: AssemblyCopyright("Copyright (c) 2009-2016 ZeroC, Inc.")]
[assembly: AssemblyVersion("4.2.1")]
[assembly: AssemblyVersion("4.2.2")]
[assembly: ComVisibleAttribute(false)]
2 changes: 1 addition & 1 deletion IceBuilder/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="ef9502be-dbc2-4568-a846-02b8e42d04c2" Version="4.2.1" Language="en-US" Publisher="ZeroC" />
<Identity Id="ef9502be-dbc2-4568-a846-02b8e42d04c2" Version="4.2.2" Language="en-US" Publisher="ZeroC" />
<DisplayName>Ice Builder</DisplayName>
<Description xml:space="preserve">Ice Builder manages the compilation of Slice (.ice) files to C++ and C#. It compiles your Slice files with slice2cpp and slice2cs, and allows you to specify the parameters provided to these compilers.</Description>
<MoreInfo>https://github.com/zeroc-ice/ice-builder-visualstudio</MoreInfo>
Expand Down
2 changes: 1 addition & 1 deletion IceBuilderTasks/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
[assembly: AssemblyCompany("ZeroC, Inc.")]
[assembly: AssemblyProduct("Ice Builder")]
[assembly: AssemblyCopyright("Copyright (c) 2009-2016 ZeroC, Inc.")]
[assembly: AssemblyVersion("4.2.1")]
[assembly: AssemblyVersion("4.2.2")]
[assembly: AssemblyDelaySign(false)]
[assembly: ComVisibleAttribute(false)]
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
[assembly: AssemblyCompany("ZeroC, Inc.")]
[assembly: AssemblyProduct("Ice Visual Studio Extension")]
[assembly: AssemblyCopyright("Copyright (c) 2009-2016 ZeroC, Inc.")]
[assembly: AssemblyVersion("4.2.0")]
[assembly: AssemblyVersion("4.2.2")]
[assembly: AssemblyDelaySign(false)]
Loading

0 comments on commit a69815f

Please sign in to comment.