Skip to content

Commit 559832b

Browse files
Remove dynamic content replacement from nuspec files
1 parent 45d6459 commit 559832b

File tree

3 files changed

+11
-26
lines changed

3 files changed

+11
-26
lines changed

templates/Microsoft.AspNetCore.SpaTemplates/Microsoft.AspNetCore.SpaTemplates.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
33
<metadata>
44
<id>Microsoft.AspNetCore.SpaTemplates</id>
5-
<version>1.0.{buildnumber}</version>
5+
<version>0.0.0</version>
66
<description>Single Page Application templates for ASP.NET Core</description>
77
<authors>Microsoft</authors>
88
<language>en-US</language>

templates/Microsoft.DotNet.Web.Spa.ProjectTemplates/Microsoft.DotNet.Web.Spa.ProjectTemplates.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
33
<metadata>
44
<id>Microsoft.DotNet.Web.Spa.ProjectTemplates</id>
5-
<version>1.0.{buildnumber}</version>
5+
<version>0.0.0</version>
66
<description>Single Page Application templates for ASP.NET Core</description>
77
<authors>Microsoft</authors>
88
<language>en-US</language>

templates/package-builder/src/build/build.ts

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -30,30 +30,13 @@ function listFilesExcludingGitignored(root: string): string[] {
3030
.filter(fn => gitignoreEvaluator.accepts(fn));
3131
}
3232

33-
function applyContentReplacements(sourceContent: Buffer, contentReplacements: { from: RegExp, to: string }[]) {
34-
let sourceText = sourceContent.toString('utf8');
35-
contentReplacements.forEach(replacement => {
36-
sourceText = sourceText.replace(replacement.from, replacement.to);
37-
});
38-
39-
return new Buffer(sourceText, 'utf8');
40-
}
41-
4233
function writeTemplate(sourceRoot: string, destRoot: string) {
4334
listFilesExcludingGitignored(sourceRoot).forEach(fn => {
4435
let sourceContent = fs.readFileSync(path.join(sourceRoot, fn));
4536
writeFileEnsuringDirExists(destRoot, fn, sourceContent);
4637
});
4738
}
4839

49-
function copyRecursive(sourceRoot: string, destRoot: string, matchGlob: string) {
50-
glob.sync(matchGlob, { cwd: sourceRoot, dot: true, nodir: true })
51-
.forEach(fn => {
52-
const sourceContent = fs.readFileSync(path.join(sourceRoot, fn));
53-
writeFileEnsuringDirExists(destRoot, fn, sourceContent);
54-
});
55-
}
56-
5740
function getBuildNumber(): string {
5841
if (process.env.APPVEYOR_BUILD_NUMBER) {
5942
return process.env.APPVEYOR_BUILD_NUMBER;
@@ -88,23 +71,25 @@ function buildDotNetNewNuGetPackage(packageId: string) {
8871
});
8972

9073
// Create the .nuspec file
91-
const nuspecContentTemplate = fs.readFileSync(path.join(packageSourceRootDir, `${ packageId }.nuspec`));
74+
const nuspecFilename = `${ packageId }.nuspec`;
75+
const nuspecContentTemplate = fs.readFileSync(path.join(packageSourceRootDir, nuspecFilename));
9276
writeFileEnsuringDirExists(outputRoot,
93-
`${ packageId }.nuspec`,
94-
applyContentReplacements(nuspecContentTemplate, [
95-
{ from: /\{buildnumber\}/g, to: getBuildNumber() },
96-
])
77+
nuspecFilename,
78+
nuspecContentTemplate
9779
);
9880

9981
// Invoke NuGet to create the final package
10082
const nugetExe = path.join(process.cwd(), './bin/NuGet.exe');
10183
const nugetStartInfo = { cwd: outputRoot, stdio: 'inherit' };
84+
const packageVersion = `1.0.${ getBuildNumber() }`;
85+
const nugetArgs = ['pack', nuspecFilename, '-Version', packageVersion];
10286
if (isWindows) {
10387
// Invoke NuGet.exe directly
104-
childProcess.spawnSync(nugetExe, ['pack'], nugetStartInfo);
88+
childProcess.spawnSync(nugetExe, nugetArgs, nugetStartInfo);
10589
} else {
10690
// Invoke via Mono (relying on that being available)
107-
childProcess.spawnSync('mono', [nugetExe, 'pack'], nugetStartInfo);
91+
nugetArgs.unshift(nugetExe);
92+
childProcess.spawnSync('mono', nugetArgs, nugetStartInfo);
10893
}
10994

11095
// Clean up

0 commit comments

Comments
 (0)