diff options
author | Rob Mensching <rob@firegiant.com> | 2023-03-16 00:44:58 -0700 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2023-03-16 02:03:40 -0700 |
commit | eac8b61c7532b96d281c3f8a088a1e78a70730bc (patch) | |
tree | 5e4607454b79365401f732c66eb29422938fe01e /src/wix/WixToolset.BuildTasks/CreateProjectReferenceDefineConstantsAndBindPaths.cs | |
parent | f586aef92e67e547cf2ea6e3259b60521695efa9 (diff) | |
download | wix-eac8b61c7532b96d281c3f8a088a1e78a70730bc.tar.gz wix-eac8b61c7532b96d281c3f8a088a1e78a70730bc.tar.bz2 wix-eac8b61c7532b96d281c3f8a088a1e78a70730bc.zip |
Handle project references that return invalid target paths
Closes 7277
Diffstat (limited to '')
-rw-r--r-- | src/wix/WixToolset.BuildTasks/CreateProjectReferenceDefineConstantsAndBindPaths.cs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/wix/WixToolset.BuildTasks/CreateProjectReferenceDefineConstantsAndBindPaths.cs b/src/wix/WixToolset.BuildTasks/CreateProjectReferenceDefineConstantsAndBindPaths.cs index ae9d8abe..8b870717 100644 --- a/src/wix/WixToolset.BuildTasks/CreateProjectReferenceDefineConstantsAndBindPaths.cs +++ b/src/wix/WixToolset.BuildTasks/CreateProjectReferenceDefineConstantsAndBindPaths.cs | |||
@@ -48,19 +48,31 @@ namespace WixToolset.BuildTasks | |||
48 | 48 | ||
49 | private void AddBindPathsForResolvedReference(IDictionary<string, List<ITaskItem>> bindPathByPaths, ITaskItem resolvedReference) | 49 | private void AddBindPathsForResolvedReference(IDictionary<string, List<ITaskItem>> bindPathByPaths, ITaskItem resolvedReference) |
50 | { | 50 | { |
51 | var projectPath = resolvedReference.GetMetadata("MSBuildSourceProjectFile"); | ||
52 | |||
51 | // If the BindName was not explicitly provided, try to use the source project's filename | 53 | // If the BindName was not explicitly provided, try to use the source project's filename |
52 | // as the bind name. | 54 | // as the bind name. |
53 | var name = resolvedReference.GetMetadata("BindName"); | 55 | var name = resolvedReference.GetMetadata("BindName"); |
54 | if (String.IsNullOrWhiteSpace(name)) | 56 | if (String.IsNullOrWhiteSpace(name)) |
55 | { | 57 | { |
56 | var projectPath = resolvedReference.GetMetadata("MSBuildSourceProjectFile"); | ||
57 | name = String.IsNullOrWhiteSpace(projectPath) ? String.Empty : Path.GetFileNameWithoutExtension(projectPath); | 58 | name = String.IsNullOrWhiteSpace(projectPath) ? String.Empty : Path.GetFileNameWithoutExtension(projectPath); |
58 | } | 59 | } |
59 | 60 | ||
60 | var path = resolvedReference.GetMetadata("BindPath"); | 61 | var path = resolvedReference.GetMetadata("BindPath"); |
61 | if (String.IsNullOrWhiteSpace(path)) | 62 | if (String.IsNullOrWhiteSpace(path)) |
62 | { | 63 | { |
63 | path = Path.GetDirectoryName(resolvedReference.GetMetadata("FullPath")); | 64 | var fullpath = resolvedReference.GetMetadata("FullPath"); |
65 | path = Path.GetDirectoryName(fullpath); | ||
66 | |||
67 | // If the resolved project reference (incorrectly) points at a file then use the file's | ||
68 | // file's directory instead. When this happens, it is a problem in the referenced project | ||
69 | // | ||
70 | while (File.Exists(path)) | ||
71 | { | ||
72 | this.Log.LogWarning("The project '{0}' target path '{1}' resolved to an invalid path where a filename was a child of a file. Using the parent directory '{2}' instead.", projectPath, fullpath, path); | ||
73 | |||
74 | path = Path.GetDirectoryName(path); | ||
75 | } | ||
64 | } | 76 | } |
65 | 77 | ||
66 | if (!bindPathByPaths.TryGetValue(path, out var bindPathsForPath) || | 78 | if (!bindPathByPaths.TryGetValue(path, out var bindPathsForPath) || |