Skip to content

Commit 890f45d

Browse files
committed
fix package id not being used
1 parent a0f4f27 commit 890f45d

4 files changed

Lines changed: 30 additions & 17 deletions

File tree

manager/Commands/Generate.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,17 @@ private static void GenerateTargetsFile(Runner runner, ReadOnlySpan<Repository>
159159
Directory.CreateDirectory(buildFolder);
160160
}
161161

162-
string targetsPath = Path.Combine(buildFolder, project.Name.ToString() + ".targets");
162+
string packageId = project.PackageId.ToString();
163+
string projectName = project.Name.ToString();
164+
if (string.IsNullOrEmpty(packageId))
165+
{
166+
packageId = projectName;
167+
}
168+
169+
string targetsPath = Path.Combine(buildFolder, packageId + ".targets");
163170
string content = TargetsTemplate.Source;
164-
content = content.Replace("{{ProjectName}}", project.Name.ToString());
171+
content = content.Replace("{{ProjectName}}", projectName);
172+
content = content.Replace("{{PackageId}}", packageId);
165173
File.WriteAllText(targetsPath, content);
166174
}
167175
}
@@ -386,15 +394,15 @@ private static string GetSource(string source, Project project)
386394
source = source.Replace("{{ProjectFolderName}}", folderName);
387395
}
388396

389-
if (source.Contains("{{PackageID}}"))
397+
if (source.Contains("{{PackageId}}"))
390398
{
391399
Text.Borrowed packageId = project.PackageId;
392400
if (packageId.IsEmpty)
393401
{
394402
packageId.CopyFrom(project.Name);
395403
}
396404

397-
source = source.Replace("{{PackageID}}", packageId.ToString());
405+
source = source.Replace("{{PackageId}}", packageId.ToString());
398406
}
399407

400408
return source;

manager/Commands/UpdateProjectFiles.cs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,21 @@ readonly void ICommand.Execute(Runner runner, Arguments arguments)
6767
private static bool EnsureBuildOutputsArePacked(Project project)
6868
{
6969
bool changed = false;
70-
string projectName = project.Name.ToString();
71-
string debugDllPath = $"bin/Debug/net9.0/{projectName}.dll";
72-
string releaseDllPath = $"bin/Release/net9.0/{projectName}.dll";
73-
string debugXmlPath = $"bin/Debug/net9.0/{projectName}.xml";
74-
string releaseXmlPath = $"bin/Release/net9.0/{projectName}.xml";
75-
string targetsPath = $"build/{projectName}.targets";
76-
string packageDebugDllPath = $"tools/debug/{projectName}.dll";
77-
string packageReleaseDllPath = $"tools/release/{projectName}.dll";
78-
string packageDebugXmlPath = $"tools/debug/{projectName}.xml";
79-
string packageReleaseXmlPath = $"tools/release/{projectName}.xml";
70+
string packageId = project.PackageId.ToString();
71+
if (string.IsNullOrEmpty(packageId))
72+
{
73+
packageId = project.Name.ToString();
74+
}
75+
76+
string debugDllPath = $"bin/Debug/net9.0/{packageId}.dll";
77+
string releaseDllPath = $"bin/Release/net9.0/{packageId}.dll";
78+
string debugXmlPath = $"bin/Debug/net9.0/{packageId}.xml";
79+
string releaseXmlPath = $"bin/Release/net9.0/{packageId}.xml";
80+
string targetsPath = $"build/{packageId}.targets";
81+
string packageDebugDllPath = $"tools/debug/{packageId}.dll";
82+
string packageReleaseDllPath = $"tools/release/{packageId}.dll";
83+
string packageDebugXmlPath = $"tools/debug/{packageId}.xml";
84+
string packageReleaseXmlPath = $"tools/release/{packageId}.xml";
8085
string debugXmlCondition = $"Exists('{debugXmlPath}')";
8186
string releaseXmlCondition = $"Exists('{releaseXmlPath}')";
8287
XMLNode debugDllPackNode = default;

manager/GitHubWorkflowTemplate.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public static class GitHubWorkflowTemplate
2424

2525
public const string PublishStep = @"
2626
- name: Publish `{{ProjectName}}`
27-
run: dotnet nuget push {{PackageID}}.${VERSION}.nupkg --source github --api-key ${NUGET_TOKEN}
27+
run: dotnet nuget push {{PackageId}}.${VERSION}.nupkg --source github --api-key ${NUGET_TOKEN}
2828
env:
2929
NUGET_TOKEN: ${{ secrets.NUGET_TOKEN }}";
3030

manager/TargetsTemplate.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ public static class TargetsTemplate
88
99
<ItemGroup Condition=""'$(Configuration)' == 'Debug'"">
1010
<Reference Include=""{{ProjectName}}"">
11-
<HintPath>$(MSBuildThisFileDirectory)..\tools\debug\{{ProjectName}}.dll</HintPath>
11+
<HintPath>$(MSBuildThisFileDirectory)..\tools\debug\{{PackageId}}.dll</HintPath>
1212
<Private>True</Private>
1313
</Reference>
1414
</ItemGroup>
1515
1616
<ItemGroup Condition=""'$(Configuration)' == 'Release'"">
1717
<Reference Include=""{{ProjectName}}"">
18-
<HintPath>$(MSBuildThisFileDirectory)..\tools\release\{{ProjectName}}.dll</HintPath>
18+
<HintPath>$(MSBuildThisFileDirectory)..\tools\release\{{PackageId}}.dll</HintPath>
1919
<Private>True</Private>
2020
</Reference>
2121
</ItemGroup>

0 commit comments

Comments
 (0)