Skip to content

Commit

Permalink
Attempt to fix #615 (#638)
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikEJ authored Oct 9, 2024
1 parent d57cf38 commit a237ebc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/DacpacTool/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,16 @@ public static string GetPostDeploymentScript(this DacPackage package)
public static void AddReference(this TSqlModel model, string referencePath, string externalParts, bool suppressErrorsForMissingDependencies)
{
ArgumentNullException.ThrowIfNull(model);
ArgumentNullException.ThrowIfNull(referencePath);

var dataSchemaModel = GetDataSchemaModel(model);

var crossPlatformPath = referencePath.Replace('\\', '/');

var customData = Activator.CreateInstance(Type.GetType("Microsoft.Data.Tools.Schema.SchemaModel.CustomSchemaData, Microsoft.Data.Tools.Schema.Sql"), "Reference", "SqlSchema");
var setMetadataMethod = customData.GetType().GetMethod("SetMetadata", BindingFlags.Public | BindingFlags.Instance);
setMetadataMethod.Invoke(customData, new object[] { "FileName", referencePath });
setMetadataMethod.Invoke(customData, new object[] { "LogicalName", Path.GetFileName(referencePath) });
setMetadataMethod.Invoke(customData, new object[] { "FileName", crossPlatformPath });
setMetadataMethod.Invoke(customData, new object[] { "LogicalName", Path.GetFileName(crossPlatformPath) });
setMetadataMethod.Invoke(customData,
new object[] { "SuppressMissingDependenciesErrors", suppressErrorsForMissingDependencies.ToString() });

Expand Down
2 changes: 1 addition & 1 deletion test/DacpacTool.Tests/ExtensionsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void CanGetReferences()

// Assert
references.Any().ShouldBeTrue();
references.First().ShouldBe(referencePackage);
references.First().ShouldBe(referencePackage.Replace('\\', '/'));
}

/// <summary>
Expand Down

0 comments on commit a237ebc

Please sign in to comment.