mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-22 17:47:53 +00:00
Remove dynamic content replacement from nuspec files
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||||
<metadata>
|
<metadata>
|
||||||
<id>Microsoft.AspNetCore.SpaTemplates</id>
|
<id>Microsoft.AspNetCore.SpaTemplates</id>
|
||||||
<version>1.0.{buildnumber}</version>
|
<version>0.0.0</version>
|
||||||
<description>Single Page Application templates for ASP.NET Core</description>
|
<description>Single Page Application templates for ASP.NET Core</description>
|
||||||
<authors>Microsoft</authors>
|
<authors>Microsoft</authors>
|
||||||
<language>en-US</language>
|
<language>en-US</language>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||||
<metadata>
|
<metadata>
|
||||||
<id>Microsoft.DotNet.Web.Spa.ProjectTemplates</id>
|
<id>Microsoft.DotNet.Web.Spa.ProjectTemplates</id>
|
||||||
<version>1.0.{buildnumber}</version>
|
<version>0.0.0</version>
|
||||||
<description>Single Page Application templates for ASP.NET Core</description>
|
<description>Single Page Application templates for ASP.NET Core</description>
|
||||||
<authors>Microsoft</authors>
|
<authors>Microsoft</authors>
|
||||||
<language>en-US</language>
|
<language>en-US</language>
|
||||||
|
|||||||
@@ -30,15 +30,6 @@ function listFilesExcludingGitignored(root: string): string[] {
|
|||||||
.filter(fn => gitignoreEvaluator.accepts(fn));
|
.filter(fn => gitignoreEvaluator.accepts(fn));
|
||||||
}
|
}
|
||||||
|
|
||||||
function applyContentReplacements(sourceContent: Buffer, contentReplacements: { from: RegExp, to: string }[]) {
|
|
||||||
let sourceText = sourceContent.toString('utf8');
|
|
||||||
contentReplacements.forEach(replacement => {
|
|
||||||
sourceText = sourceText.replace(replacement.from, replacement.to);
|
|
||||||
});
|
|
||||||
|
|
||||||
return new Buffer(sourceText, 'utf8');
|
|
||||||
}
|
|
||||||
|
|
||||||
function writeTemplate(sourceRoot: string, destRoot: string) {
|
function writeTemplate(sourceRoot: string, destRoot: string) {
|
||||||
listFilesExcludingGitignored(sourceRoot).forEach(fn => {
|
listFilesExcludingGitignored(sourceRoot).forEach(fn => {
|
||||||
let sourceContent = fs.readFileSync(path.join(sourceRoot, fn));
|
let sourceContent = fs.readFileSync(path.join(sourceRoot, fn));
|
||||||
@@ -46,14 +37,6 @@ function writeTemplate(sourceRoot: string, destRoot: string) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function copyRecursive(sourceRoot: string, destRoot: string, matchGlob: string) {
|
|
||||||
glob.sync(matchGlob, { cwd: sourceRoot, dot: true, nodir: true })
|
|
||||||
.forEach(fn => {
|
|
||||||
const sourceContent = fs.readFileSync(path.join(sourceRoot, fn));
|
|
||||||
writeFileEnsuringDirExists(destRoot, fn, sourceContent);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function getBuildNumber(): string {
|
function getBuildNumber(): string {
|
||||||
if (process.env.APPVEYOR_BUILD_NUMBER) {
|
if (process.env.APPVEYOR_BUILD_NUMBER) {
|
||||||
return process.env.APPVEYOR_BUILD_NUMBER;
|
return process.env.APPVEYOR_BUILD_NUMBER;
|
||||||
@@ -88,23 +71,25 @@ function buildDotNetNewNuGetPackage(packageId: string) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Create the .nuspec file
|
// Create the .nuspec file
|
||||||
const nuspecContentTemplate = fs.readFileSync(path.join(packageSourceRootDir, `${ packageId }.nuspec`));
|
const nuspecFilename = `${ packageId }.nuspec`;
|
||||||
|
const nuspecContentTemplate = fs.readFileSync(path.join(packageSourceRootDir, nuspecFilename));
|
||||||
writeFileEnsuringDirExists(outputRoot,
|
writeFileEnsuringDirExists(outputRoot,
|
||||||
`${ packageId }.nuspec`,
|
nuspecFilename,
|
||||||
applyContentReplacements(nuspecContentTemplate, [
|
nuspecContentTemplate
|
||||||
{ from: /\{buildnumber\}/g, to: getBuildNumber() },
|
|
||||||
])
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Invoke NuGet to create the final package
|
// Invoke NuGet to create the final package
|
||||||
const nugetExe = path.join(process.cwd(), './bin/NuGet.exe');
|
const nugetExe = path.join(process.cwd(), './bin/NuGet.exe');
|
||||||
const nugetStartInfo = { cwd: outputRoot, stdio: 'inherit' };
|
const nugetStartInfo = { cwd: outputRoot, stdio: 'inherit' };
|
||||||
|
const packageVersion = `1.0.${ getBuildNumber() }`;
|
||||||
|
const nugetArgs = ['pack', nuspecFilename, '-Version', packageVersion];
|
||||||
if (isWindows) {
|
if (isWindows) {
|
||||||
// Invoke NuGet.exe directly
|
// Invoke NuGet.exe directly
|
||||||
childProcess.spawnSync(nugetExe, ['pack'], nugetStartInfo);
|
childProcess.spawnSync(nugetExe, nugetArgs, nugetStartInfo);
|
||||||
} else {
|
} else {
|
||||||
// Invoke via Mono (relying on that being available)
|
// Invoke via Mono (relying on that being available)
|
||||||
childProcess.spawnSync('mono', [nugetExe, 'pack'], nugetStartInfo);
|
nugetArgs.unshift(nugetExe);
|
||||||
|
childProcess.spawnSync('mono', nugetArgs, nugetStartInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean up
|
// Clean up
|
||||||
|
|||||||
Reference in New Issue
Block a user