Browse Source

Diff menu item in WiX setup files editor now shows new directories that are missing from setup.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@3219 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Matt Ward 17 years ago
parent
commit
fc1a8bb8ec
  1. 29
      src/AddIns/BackendBindings/WixBinding/Project/Src/WixPackageFilesDiff.cs
  2. 15
      src/AddIns/BackendBindings/WixBinding/Project/Src/WixPackageFilesDiffResult.cs
  3. 100
      src/AddIns/BackendBindings/WixBinding/Test/Diff/MissingDirectoryTestFixture.cs
  4. 7
      src/AddIns/BackendBindings/WixBinding/Test/Diff/NoDifferentFilesTestFixture.cs
  5. 1
      src/AddIns/BackendBindings/WixBinding/Test/WixBinding.Tests.csproj

29
src/AddIns/BackendBindings/WixBinding/Project/Src/WixPackageFilesDiff.cs

@ -85,7 +85,7 @@ namespace ICSharpCode.WixBinding @@ -85,7 +85,7 @@ namespace ICSharpCode.WixBinding
}
}
}
// Add new files.
List<WixPackageFilesDiffResult> results = new List<WixPackageFilesDiffResult>();
foreach (string fileName in files) {
@ -96,6 +96,9 @@ namespace ICSharpCode.WixBinding @@ -96,6 +96,9 @@ namespace ICSharpCode.WixBinding
foreach (string fileName in missingFiles) {
results.Add(new WixPackageFilesDiffResult(fileName, WixPackageFilesDiffResultType.MissingFile));
}
// Add new directories.
results.AddRange(GetNewDirectories());
return results.ToArray();
}
@ -155,5 +158,29 @@ namespace ICSharpCode.WixBinding @@ -155,5 +158,29 @@ namespace ICSharpCode.WixBinding
searchedDirectories.Add(directory);
return false;
}
/// <summary>
/// Looks for new subdirectories that are not included in those searched.
/// </summary>
/// <remarks>
/// TODO: Should not be using ExcludedFileNames to check whether the directory should be added.
/// </remarks>
List<WixPackageFilesDiffResult> GetNewDirectories()
{
List<WixPackageFilesDiffResult> results = new List<WixPackageFilesDiffResult>();
string[] directories = new string[searchedDirectories.Count];
searchedDirectories.CopyTo(directories);
foreach (string directory in directories) {
foreach (string subDirectory in directoryReader.GetDirectories(directory)) {
DirectoryInfo dirInfo = new DirectoryInfo(subDirectory);
if (!excludedFileNames.IsExcluded(dirInfo.Name)) {
if (!HasDirectoryBeenSearched(subDirectory)) {
results.Add(new WixPackageFilesDiffResult(subDirectory, WixPackageFilesDiffResultType.NewDirectory));
}
}
}
}
return results;
}
}
}

15
src/AddIns/BackendBindings/WixBinding/Project/Src/WixPackageFilesDiffResult.cs

@ -19,7 +19,12 @@ namespace ICSharpCode.WixBinding @@ -19,7 +19,12 @@ namespace ICSharpCode.WixBinding
/// <summary>
/// The file is new and does not exist in the WixDocument.
/// </summary>
NewFile
NewFile,
/// <summary>
/// The file is new and does not exist in the WixDocument.
/// </summary>
NewDirectory
}
/// <summary>
@ -38,15 +43,11 @@ namespace ICSharpCode.WixBinding @@ -38,15 +43,11 @@ namespace ICSharpCode.WixBinding
}
public WixPackageFilesDiffResultType DiffType {
get {
return diffType;
}
get { return diffType; }
}
public string FileName {
get {
return fileName;
}
get { return fileName; }
}
}
}

100
src/AddIns/BackendBindings/WixBinding/Test/Diff/MissingDirectoryTestFixture.cs

@ -0,0 +1,100 @@ @@ -0,0 +1,100 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using ICSharpCode.WixBinding;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace WixBinding.Tests.Diff
{
/// <summary>
/// If there is a new directory which is not included in the setup then this should be returned
/// in the diff result.
/// </summary>
[TestFixture]
public class MissingDirectoryTestFixture : IDirectoryReader
{
WixPackageFilesDiffResult[] diffResults;
[TestFixtureSetUp]
public void SetUpFixture()
{
WixDocument doc = new WixDocument();
doc.FileName = @"C:\Projects\Setup\Setup.wxs";
doc.LoadXml(GetWixXml());
WixPackageFilesDiff diff = new WixPackageFilesDiff(this);
diff.ExcludedFileNames.Add(".svn");
diffResults = diff.Compare(doc.RootDirectory);
}
[Test]
public void OneDiffResultFound()
{
StringBuilder fileNames = new StringBuilder();
foreach (WixPackageFilesDiffResult result in diffResults) {
fileNames.AppendLine(result.FileName);
}
Assert.AreEqual(1, diffResults.Length, fileNames.ToString());
}
[Test]
public void DiffResultFileName()
{
Assert.AreEqual(@"c:\projects\setup\bin\addins", diffResults[0].FileName.ToLowerInvariant());
}
[Test]
public void DiffResultType()
{
Assert.AreEqual(WixPackageFilesDiffResultType.NewDirectory, diffResults[0].DiffType);
}
public string[] GetFiles(string path)
{
if (path.StartsWith(@"C:\Projects\Setup\bin")) {
return new string[] {@"license.rtf"};
}
return new string[0];
}
public string[] GetDirectories(string path)
{
return new string[] { Path.Combine(path, "AddIns"), Path.Combine(path, ".svn")};
}
public bool DirectoryExists(string path)
{
return true;
}
string GetWixXml()
{
return "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>\r\n" +
"\t<Product Name='Test' \r\n" +
"\t Version='1.0' \r\n" +
"\t Language='1013' \r\n" +
"\t Manufacturer='#develop' \r\n" +
"\t Id='????????-????-????-????-????????????'>\r\n" +
"\t\t<Package/>\r\n" +
"\t\t<Directory Id='TARGETDIR' SourceName='SourceDir'>\r\n" +
"\t\t\t<Directory Id='ProgramFilesFolder' Name='PFiles'>\r\n" +
"\t\t\t\t<Directory Id='INSTALLDIR' Name='YourApp' LongName='Your Application'>\r\n" +
"\t\t\t\t\t<Component Id='MyComponent' DiskId='1'>\r\n" +
"\t\t\t\t\t\t<File Id='LicenseFile' Name='license.rtf' Source='bin\\license.rtf' />\r\n" +
"\t\t\t\t\t</Component>\r\n" +
"\t\t\t\t</Directory>\r\n" +
"\t\t\t</Directory>\r\n" +
"\t\t</Directory>\r\n" +
"\t</Product>\r\n" +
"</Wix>";
}
}
}

7
src/AddIns/BackendBindings/WixBinding/Test/Diff/NoDifferentFilesTestFixture.cs

@ -9,6 +9,7 @@ using ICSharpCode.WixBinding; @@ -9,6 +9,7 @@ using ICSharpCode.WixBinding;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Text;
namespace WixBinding.Tests.Diff
{
@ -47,7 +48,11 @@ namespace WixBinding.Tests.Diff @@ -47,7 +48,11 @@ namespace WixBinding.Tests.Diff
[Test]
public void DirectoryExistsChecks()
{
Assert.AreEqual(1, directoryExistsChecks.Count);
StringBuilder directoriesChecked = new StringBuilder();
foreach (string dir in directoryExistsChecks) {
directoriesChecked.AppendLine(dir);
}
Assert.AreEqual(1, directoryExistsChecks.Count, directoriesChecked.ToString());
Assert.AreEqual(@"C:\Projects\Setup\bin", directoryExistsChecks[0]);
}

1
src/AddIns/BackendBindings/WixBinding/Test/WixBinding.Tests.csproj

@ -49,6 +49,7 @@ @@ -49,6 +49,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="Diff\MissingDirectoryTestFixture.cs" />
<Compile Include="Document\NewWixFileElementTests.cs" />
<Compile Include="Gui\AddDialogsToSetupDialogListTestFixture.cs" />
<Compile Include="Gui\DeleteWixExtensionNodeTestFixture.cs" />

Loading…
Cancel
Save