Remove dynamic content replacement from nuspec files
This commit is contained in:
Родитель
45d645931b
Коммит
559832bb6d
|
@ -2,7 +2,7 @@
|
|||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||
<metadata>
|
||||
<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>
|
||||
<authors>Microsoft</authors>
|
||||
<language>en-US</language>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||
<metadata>
|
||||
<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>
|
||||
<authors>Microsoft</authors>
|
||||
<language>en-US</language>
|
||||
|
|
|
@ -30,15 +30,6 @@ function listFilesExcludingGitignored(root: string): string[] {
|
|||
.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) {
|
||||
listFilesExcludingGitignored(sourceRoot).forEach(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 {
|
||||
if (process.env.APPVEYOR_BUILD_NUMBER) {
|
||||
return process.env.APPVEYOR_BUILD_NUMBER;
|
||||
|
@ -88,23 +71,25 @@ function buildDotNetNewNuGetPackage(packageId: string) {
|
|||
});
|
||||
|
||||
// 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,
|
||||
`${ packageId }.nuspec`,
|
||||
applyContentReplacements(nuspecContentTemplate, [
|
||||
{ from: /\{buildnumber\}/g, to: getBuildNumber() },
|
||||
])
|
||||
nuspecFilename,
|
||||
nuspecContentTemplate
|
||||
);
|
||||
|
||||
// Invoke NuGet to create the final package
|
||||
const nugetExe = path.join(process.cwd(), './bin/NuGet.exe');
|
||||
const nugetStartInfo = { cwd: outputRoot, stdio: 'inherit' };
|
||||
const packageVersion = `1.0.${ getBuildNumber() }`;
|
||||
const nugetArgs = ['pack', nuspecFilename, '-Version', packageVersion];
|
||||
if (isWindows) {
|
||||
// Invoke NuGet.exe directly
|
||||
childProcess.spawnSync(nugetExe, ['pack'], nugetStartInfo);
|
||||
childProcess.spawnSync(nugetExe, nugetArgs, nugetStartInfo);
|
||||
} else {
|
||||
// Invoke via Mono (relying on that being available)
|
||||
childProcess.spawnSync('mono', [nugetExe, 'pack'], nugetStartInfo);
|
||||
nugetArgs.unshift(nugetExe);
|
||||
childProcess.spawnSync('mono', nugetArgs, nugetStartInfo);
|
||||
}
|
||||
|
||||
// Clean up
|
||||
|
|
Загрузка…
Ссылка в новой задаче