Skip to content

Commit 13597ca

Browse files
Fix bare References and update convertToSDK.py script
Fixed bare Reference elements in FieldWorks.csproj and XMLViews.csproj that should have been PackageReferences: - Geckofx60.32/64 packages (provide Geckofx-Core, Geckofx-Winforms) - SharpZipLib (provides ICSharpCode.SharpZipLib) - SIL.ParatextShared (provides ParatextShared) Updated convertToSDK.py to use mkall.targets-based NuGet detection instead of unreliable path-based heuristics: - Added _load_nuget_assemblies_from_mkall_targets() method - Loads assemblies from ItemGroups (PalasoFiles, ChorusFiles, etc.) - Maps package names to assembly names (SharpZipLib -> ICSharpCode.SharpZipLib) - Updated _extract_references() to check nuget_assembly_names This ensures all NuGet packages are properly identified and converted to PackageReferences during SDK conversion. Co-authored-by: jasonleenaylor <[email protected]>
1 parent 29a0b64 commit 13597ca

File tree

3 files changed

+81
-16
lines changed

3 files changed

+81
-16
lines changed

Build/convertToSDK.py

Lines changed: 74 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ def __init__(self, repo_root):
3737
# SIL.Core version mapping - prefer the newer version
3838
self.sil_core_version = "15.0.0-beta0117"
3939

40+
# Load NuGet assembly names from mkall.targets
41+
self.nuget_assembly_names = self._load_nuget_assemblies_from_mkall_targets()
42+
logger.info(f"Loaded {len(self.nuget_assembly_names)} NuGet assembly names from mkall.targets")
43+
4044
# Build maps for intelligent reference resolution
4145
self.assembly_to_project_map = {} # assembly name -> project path
4246
self.package_names = set(self.all_packages.keys()) # set of package names for quick lookup
@@ -135,6 +139,67 @@ def _load_packages_config(self, packages_file):
135139

136140
return packages
137141

142+
def _load_nuget_assemblies_from_mkall_targets(self):
143+
"""Load NuGet assembly names from mkall.targets ItemGroups"""
144+
nuget_assemblies = set()
145+
mkall_targets_path = self.repo_root / "Build" / "mkall.targets"
146+
147+
if not mkall_targets_path.exists():
148+
logger.warning(f"mkall.targets file not found: {mkall_targets_path}")
149+
return nuget_assemblies
150+
151+
try:
152+
tree = ET.parse(mkall_targets_path)
153+
root = tree.getroot()
154+
ns = {'ms': 'http://schemas.microsoft.com/developer/msbuild/2003'}
155+
156+
# ItemGroups that contain NuGet assembly names
157+
nuget_itemgroups = [
158+
'PalasoFiles', 'ChorusFiles', 'LcmOutputBaseFiles',
159+
'LcmToolsBaseFiles', 'LcmBuildTasksBaseFiles'
160+
]
161+
162+
for itemgroup_name in nuget_itemgroups:
163+
for item in root.findall(f'.//ms:{itemgroup_name}', ns):
164+
include_attr = item.get('Include')
165+
if include_attr:
166+
# Remove .dll extension if present
167+
assembly_name = include_attr.replace('.dll', '')
168+
nuget_assemblies.add(assembly_name)
169+
logger.debug(f"Found NuGet assembly from {itemgroup_name}: {assembly_name}")
170+
171+
# Also extract from package names - some packages have different assembly names
172+
# Add common NuGet packages from packages.config that might not be in mkall.targets
173+
for package_name in self.all_packages.keys():
174+
# Map package names to their likely assembly names
175+
assembly_mappings = {
176+
'SharpZipLib': 'ICSharpCode.SharpZipLib',
177+
'Geckofx60.32': 'Geckofx-Core', # Both x32 and x64 provide the same assemblies
178+
'Geckofx60.64': 'Geckofx-Core',
179+
'SIL.ParatextShared': 'ParatextShared',
180+
}
181+
182+
# Add the package name itself
183+
nuget_assemblies.add(package_name)
184+
185+
# Add any mapped assembly names
186+
if package_name in assembly_mappings:
187+
mapped_name = assembly_mappings[package_name]
188+
nuget_assemblies.add(mapped_name)
189+
# Geckofx packages provide both Core and Winforms
190+
if 'Geckofx' in package_name:
191+
nuget_assemblies.add('Geckofx-Winforms')
192+
logger.debug(f"Mapped package {package_name} -> assembly {mapped_name}")
193+
194+
logger.info(f"Loaded {len(nuget_assemblies)} NuGet assemblies from mkall.targets and package mappings")
195+
196+
except ET.ParseError as e:
197+
logger.error(f"Error parsing mkall.targets: {e}")
198+
except Exception as e:
199+
logger.error(f"Error loading NuGet assemblies from mkall.targets: {e}")
200+
201+
return nuget_assemblies
202+
138203
def _get_target_framework_from_version(self, version_string):
139204
"""Convert TargetFrameworkVersion to TargetFramework"""
140205
version_map = {
@@ -187,15 +252,17 @@ def _extract_references(self, root, ns):
187252
for ref in root.findall('.//ms:Reference', ns):
188253
include = ref.get('Include')
189254
if include:
190-
# Check if it's a NuGet package or system reference
191-
hint_path = ref.find('ms:HintPath', ns)
192-
if hint_path is not None and ('packages' in hint_path.text or 'nuget' in hint_path.text.lower()):
193-
# This is likely a NuGet package reference
194-
package_name = include.split(',')[0] # Remove version info
195-
references.append(('package', package_name))
255+
# Remove version info from assembly name
256+
assembly_name = include.split(',')[0]
257+
258+
# Check if it's a NuGet package using mkall.targets information
259+
if assembly_name in self.nuget_assembly_names:
260+
# This is a NuGet package reference
261+
references.append(('package', assembly_name))
262+
logger.debug(f"Identified '{assembly_name}' as NuGet package from mkall.targets")
196263
else:
197264
# System or local reference
198-
references.append(('reference', include.split(',')[0]))
265+
references.append(('reference', assembly_name))
199266

200267
# Extract ProjectReferences
201268
for proj_ref in root.findall('.//ms:ProjectReference', ns):

Src/Common/Controls/XMLViews/XMLViews.csproj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,20 @@
3939

4040
<ItemGroup>
4141
<PackageReference Include="CommonServiceLocator" Version="2.0.7" Exclude="Build,Analyzers" />
42+
<PackageReference Include="Geckofx60.32" Version="60.0.50" Condition="'$(Platform)' != 'x64'" />
43+
<PackageReference Include="Geckofx60.64" Version="60.0.50" Condition="'$(Platform)' == 'x64'" />
4244
<PackageReference Include="SIL.Core" Version="15.0.0-beta0117" />
4345
<PackageReference Include="SIL.Core.Desktop" Version="15.0.0-beta0117" />
4446
<PackageReference Include="SIL.LCModel" Version="11.0.0-*" />
4547
<PackageReference Include="SIL.LCModel.Core" Version="11.0.0-*" />
4648
<PackageReference Include="SIL.LCModel.Utils" Version="11.0.0-*" />
4749
<PackageReference Include="SIL.Windows.Forms" Version="15.0.0-beta0117" />
4850
<PackageReference Include="SIL.WritingSystems" Version="15.0.0-beta0117" />
49-
5051
</ItemGroup>
5152

5253
<ItemGroup>
5354
<Reference Include="Accessibility" />
5455
<Reference Include="ECInterfaces" />
55-
<Reference Include="Geckofx-Core" />
56-
<Reference Include="Geckofx-Winforms" />
5756
<Reference Include="SilEncConverters40" />
5857
<Reference Include="System.Drawing" />
5958
<Reference Include="System.Windows.Forms" />

Src/Common/FieldWorks/FieldWorks.csproj

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,27 +37,26 @@
3737

3838
<ItemGroup>
3939
<PackageReference Include="CommonServiceLocator" Version="2.0.7" Exclude="Build,Analyzers" />
40+
<PackageReference Include="Geckofx60.32" Version="60.0.50" Condition="'$(Platform)' != 'x64'" />
41+
<PackageReference Include="Geckofx60.64" Version="60.0.50" Condition="'$(Platform)' == 'x64'" />
4042
<PackageReference Include="L10NSharp" Version="7.0.0" />
43+
<PackageReference Include="SharpZipLib" Version="1.4.0" Exclude="Build,Analyzers" />
4144
<PackageReference Include="SIL.Core" Version="15.0.0-beta0117" />
4245
<PackageReference Include="SIL.Core.Desktop" Version="15.0.0-beta0117" />
46+
<PackageReference Include="SIL.DesktopAnalytics" Version="4.0.0" />
4347
<PackageReference Include="SIL.LCModel" Version="11.0.0-*" />
4448
<PackageReference Include="SIL.LCModel.Core" Version="11.0.0-*" />
4549
<PackageReference Include="SIL.LCModel.Utils" Version="11.0.0-*" />
4650
<PackageReference Include="SIL.Lexicon" Version="15.0.0-beta0117" />
51+
<PackageReference Include="SIL.ParatextShared" Version="7.4.0.1" />
4752
<PackageReference Include="SIL.Windows.Forms" Version="15.0.0-beta0117" />
4853
<PackageReference Include="SIL.Windows.Forms.Keyboarding" Version="15.0.0-beta0117" />
4954
<PackageReference Include="SIL.WritingSystems" Version="15.0.0-beta0117" />
50-
<PackageReference Include="SIL.DesktopAnalytics" Version="4.0.0" />
51-
5255
</ItemGroup>
5356

5457
<ItemGroup>
55-
<Reference Include="Geckofx-Core" />
56-
<Reference Include="Geckofx-Winforms" />
57-
<Reference Include="ICSharpCode.SharpZipLib" />
5858
<Reference Include="Microsoft.Build.Framework" />
5959
<Reference Include="PaToFdoInterfaces" />
60-
<Reference Include="ParatextShared" />
6160
<Reference Include="System.Configuration" />
6261
<Reference Include="System.Drawing" />
6362
<Reference Include="System.Net" />

0 commit comments

Comments
 (0)