diff options
author | Matt Ward <matt.ward@xamarin.com> | 2015-08-13 17:34:40 +0300 |
---|---|---|
committer | Matt Ward <matt.ward@xamarin.com> | 2015-08-13 17:34:40 +0300 |
commit | 053dbac10e7c106b52f34ee35161b63a29842ae3 (patch) | |
tree | 9c35ed7027caff05476b024ec4d04fb25c52343d /main/src/addins/MonoDevelop.PackageManagement | |
parent | 8bd7ad1c22ac6956ee72bd95702a027afc355e20 (diff) |
[NuGet] Fix build task not updated for Xamarin.Forms.
Fixed bug #32162 - Error initializing task
FixedCreateCSharpManifestResourceName when updating Forms NuGet package.
https://bugzilla.xamarin.com/show_bug.cgi?id=32162
If a solution that has multiple projects that reference Xamarin.Forms
is built once and then the NuGet package is updated the old MSBuild
task dll is still used when compiling.
To reproduce this bug:
1) Create a Xamarin.Forms project (PCL + Android + iOS).
2) Install Xamarin.Forms 1.4.3.6376 into each project.
3) Compile the solution.
4) Update Xamarin.Forms to version 1.4.4-pre3 or higher.
5) Rebuild the solution.
6) Build fails with:
Error initializing task FixedCreateCSharpManifestResourceName: Not
registered task FixedCreateCSharpManifestResourceName.
The FixedCreateCSharpManifestResourceName is a new task made available
in the newer version of Xamarin.Forms. The MSBuild host was still
using the old Xamarin.Forms.Build.Tasks.dll version 1.4.3. The NuGet
addin was only disposing the project builder for the project being
updated. If there are multiple projects in the solution the MSBuild
host would not be stopped so the old build task would still be used.
Now the NuGet addin will dispose the project builders for all projects
in the solution if an import was removed whilst updating the NuGet
package. This results in the MSBuild host being stopped and then
when the next build is done the MSBuild host is restarted and uses the
correct build task dll.
This is a change to the fix implemented in commit ac84628953fb45b87804c7c8112f52ff431e8a45
Diffstat (limited to 'main/src/addins/MonoDevelop.PackageManagement')
8 files changed, 98 insertions, 4 deletions
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/MonoDevelopProjectSystemTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/MonoDevelopProjectSystemTests.cs index 9d67d3f590..fd3280c147 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/MonoDevelopProjectSystemTests.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/MonoDevelopProjectSystemTests.cs @@ -1133,17 +1133,24 @@ namespace MonoDevelop.PackageManagement.Tests }
[Test]
- public void RemoveImport_ImportAlreadyAddedToBottomOfProject_ProjectBuilderIsDisposed ()
+ public void RemoveImport_ImportAlreadyAddedToBottomOfProject_ImportRemovedEventIsFired ()
{
CreateTestProject (@"d:\projects\MyProject\MyProject\MyProject.csproj");
CreateProjectSystem (project);
string targetPath = @"d:\projects\MyProject\packages\Foo.0.1\build\Foo.targets".ToNativePath ();
projectSystem.AddImport (targetPath, ProjectImportLocation.Bottom);
+ const string expectedImportRemoved = @"..\packages\Foo.0.1\build\Foo.targets";
+ DotNetProjectImportEventArgs eventArgs = null;
+ projectSystem.PackageManagementEvents.ImportRemoved += (sender, e) => {
+ eventArgs = e;
+ };
projectSystem.RemoveImport (targetPath);
- AssertImportRemoved (@"..\packages\Foo.0.1\build\Foo.targets");
- Assert.IsTrue (project.IsProjectBuilderDisposed);
+ AssertImportRemoved (expectedImportRemoved);
+ Assert.IsFalse (project.IsProjectBuilderDisposed);
+ Assert.AreEqual (project, eventArgs.Project);
+ Assert.AreEqual (expectedImportRemoved, eventArgs.Import);
}
[Test]
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.csproj b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.csproj index 28a2416b09..111d26d622 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.csproj +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.csproj @@ -374,6 +374,7 @@ <Compile Include="MonoDevelop.PackageManagement\DotNetProjectReferenceEventArgs.cs" /> <Compile Include="MonoDevelop.PackageManagement\LocalCopyReferenceMaintainer.cs" /> <Compile Include="MonoDevelop.PackageManagement\DotNetSolutionEventArgs.cs" /> + <Compile Include="MonoDevelop.PackageManagement\DotNetProjectImportEventArgs.cs" /> </ItemGroup> <ItemGroup> <EmbeddedResource Include="MonoDevelop.PackageManagement.addin.xml" /> diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/DotNetProjectImportEventArgs.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/DotNetProjectImportEventArgs.cs new file mode 100644 index 0000000000..cf0b696498 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/DotNetProjectImportEventArgs.cs @@ -0,0 +1,43 @@ +//
+// DotNetProjectImportEventArgs.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+
+namespace MonoDevelop.PackageManagement
+{
+ public class DotNetProjectImportEventArgs : EventArgs
+ {
+ public DotNetProjectImportEventArgs (IDotNetProject project, string import)
+ {
+ Project = project;
+ Import = import;
+ }
+
+ public IDotNetProject Project { get; private set; }
+ public string Import { get; private set; }
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageManagementEvents.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageManagementEvents.cs index 5b0bb4fb1f..c830df588d 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageManagementEvents.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageManagementEvents.cs @@ -54,6 +54,7 @@ namespace ICSharpCode.PackageManagement event EventHandler<PackageRestoredEventArgs> PackageRestored;
event EventHandler<DotNetProjectReferenceEventArgs> ReferenceAdding;
event EventHandler<DotNetProjectReferenceEventArgs> ReferenceRemoving;
+ event EventHandler<DotNetProjectImportEventArgs> ImportRemoved;
void OnPackageOperationsStarting();
void OnPackageOperationsFinished();
@@ -72,6 +73,7 @@ namespace ICSharpCode.PackageManagement void OnPackageRestored (IPackage package);
void OnReferenceAdding (ProjectReference reference);
void OnReferenceRemoving (ProjectReference reference);
+ void OnImportRemoved (IDotNetProject project, string import);
[Obsolete]
void OnParentPackageInstalled (IPackage package, IPackageManagementProject project);
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementEvents.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementEvents.cs index f6462784f2..fa67203211 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementEvents.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementEvents.cs @@ -209,5 +209,14 @@ namespace ICSharpCode.PackageManagement ReferenceAdding (this, new DotNetProjectReferenceEventArgs (reference));
}
}
+
+ public event EventHandler<DotNetProjectImportEventArgs> ImportRemoved;
+
+ public void OnImportRemoved (IDotNetProject project, string import)
+ {
+ if (ImportRemoved != null) {
+ ImportRemoved (this, new DotNetProjectImportEventArgs (project, import));
+ }
+ }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementEventsMonitor.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementEventsMonitor.cs index 39df61d6e9..5e8ec633b8 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementEventsMonitor.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementEventsMonitor.cs @@ -45,6 +45,7 @@ namespace MonoDevelop.PackageManagement string currentProgressOperation;
List<FileEventArgs> fileChangedEvents = new List<FileEventArgs> ();
List<IPackageManagementProject> projectsRequiringTypeSystemRefresh = new List<IPackageManagementProject> ();
+ ISolution solutionContainingProjectBuildersToDispose;
public PackageManagementEventsMonitor (
IProgressMonitor progressMonitor,
@@ -60,12 +61,14 @@ namespace MonoDevelop.PackageManagement packageManagementEvents.AcceptLicenses += AcceptLicenses;
packageManagementEvents.FileChanged += FileChanged;
packageManagementEvents.ParentPackageInstalled += PackageInstalled;
+ packageManagementEvents.ImportRemoved += ImportRemoved;
progressProvider.ProgressAvailable += ProgressAvailable;
}
public void Dispose ()
{
progressProvider.ProgressAvailable -= ProgressAvailable;
+ packageManagementEvents.ImportRemoved -= ImportRemoved;
packageManagementEvents.ParentPackageInstalled -= PackageInstalled;
packageManagementEvents.FileChanged -= FileChanged;
packageManagementEvents.AcceptLicenses -= AcceptLicenses;
@@ -73,6 +76,7 @@ namespace MonoDevelop.PackageManagement packageManagementEvents.PackageOperationMessageLogged -= PackageOperationMessageLogged;
NotifyFilesChanged ();
+ UnloadMSBuildHost ();
RefreshTypeSystem ();
}
@@ -232,6 +236,23 @@ namespace MonoDevelop.PackageManagement return (operation.Action == PackageAction.Install) &&
operation.Package.GetBuildFiles ().Any ();
}
+
+ void ImportRemoved (object sender, DotNetProjectImportEventArgs e)
+ {
+ solutionContainingProjectBuildersToDispose = e.Project.ParentSolution;
+ }
+
+ void UnloadMSBuildHost ()
+ {
+ if (solutionContainingProjectBuildersToDispose == null)
+ return;
+
+ GuiSyncDispatch (() => {
+ foreach (IDotNetProject project in solutionContainingProjectBuildersToDispose.GetAllProjects ()) {
+ project.DisposeProjectBuilder ();
+ }
+ });
+ }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SharpDevelopProjectSystem.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SharpDevelopProjectSystem.cs index 87c1707789..4684a24b57 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SharpDevelopProjectSystem.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SharpDevelopProjectSystem.cs @@ -426,9 +426,10 @@ namespace ICSharpCode.PackageManagement using (var updater = new EnsureNuGetPackageBuildImportsTargetUpdater ()) {
updater.RemoveImport (relativeTargetPath);
- project.DisposeProjectBuilder ();
project.Save ();
}
+
+ packageManagementEvents.OnImportRemoved (project, relativeTargetPath);
});
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ThreadSafePackageManagementEvents.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ThreadSafePackageManagementEvents.cs index 5fd0086856..d85e9f4457 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ThreadSafePackageManagementEvents.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ThreadSafePackageManagementEvents.cs @@ -319,5 +319,15 @@ namespace ICSharpCode.PackageManagement {
unsafeEvents.OnReferenceRemoving (reference);
}
+
+ public event EventHandler<DotNetProjectImportEventArgs> ImportRemoved {
+ add { unsafeEvents.ImportRemoved += value; }
+ remove { unsafeEvents.ImportRemoved -= value; }
+ }
+
+ public void OnImportRemoved (IDotNetProject project, string import)
+ {
+ unsafeEvents.OnImportRemoved (project, import);
+ }
}
}
|