@@ -5,7 +5,7 @@ import * as path from 'path';
55var camelCase = require ( 'camel-case' )
66import { execAsync } from './asyncprocess' ;
77
8- const nbgvPath = 'nbgv.nuget ' ;
8+ const nbgvPath = 'nbgv.cli ' ;
99
1010/**
1111 * The various aspects of a version that can be calculated.
@@ -42,25 +42,16 @@ export interface IGitVersion {
4242 */
4343export async function getVersion ( projectDirectory ?: string ) : Promise < IGitVersion > {
4444 projectDirectory = projectDirectory || '.' ;
45- var getVersionScriptPath = path . join ( __dirname , nbgvPath , "tools" , "Get-Version.ps1 " ) ;
46- var versionText = await execAsync ( `powershell -ExecutionPolicy Bypass -Command "& ' ${ getVersionScriptPath } ' -ProjectDirectory ' ${ projectDirectory } '" ` )
45+ var getVersionScriptPath = path . join ( __dirname , nbgvPath , "tools" , "netcoreapp2.1" , "any" , "nbgv.dll ") ;
46+ var versionText = await execAsync ( `dotnet " ${ getVersionScriptPath } " get-version --project " ${ projectDirectory } " --format json ` )
4747 if ( versionText . stderr ) {
4848 throw versionText . stderr ;
4949 }
5050
51- var varsRegEx = / ^ ( \w + ) \s * : ( .+ ) / mg;
52- var match ;
51+ var directResult = JSON . parse ( versionText . stdout ) ;
5352 var result = { } ;
54- while ( match = varsRegEx . exec ( versionText . stdout ) ) {
55- // Do a few type casts if appropriate.
56- let value = match [ 2 ] ;
57- if ( value . toUpperCase ( ) === 'TRUE' ) {
58- value = true ;
59- } else if ( value . toUpperCase ( ) === 'FALSE' ) {
60- value = false ;
61- }
62-
63- result [ camelCase ( match [ 1 ] ) ] = value ;
53+ for ( var field in directResult ) {
54+ result [ camelCase ( field ) ] = directResult [ field ] ;
6455 }
6556
6657 return < IGitVersion > result ;
@@ -69,7 +60,7 @@ export async function getVersion(projectDirectory?: string): Promise<IGitVersion
6960/**
7061 * Sets an NPM package version based on the git height and version.json.
7162 * @param packageDirectory The directory of the package about to be published.
72- * @param srcDirectory The directory of the source code behind the package, if different than the packageDirectory.
63+ * @param srcDirectory The directory of the source code behind the package, if different than the packageDirectory.
7364 */
7465export async function setPackageVersion ( packageDirectory ?: string , srcDirectory ?: string ) {
7566 packageDirectory = packageDirectory || '.' ;
@@ -85,7 +76,7 @@ export async function setPackageVersion(packageDirectory?: string, srcDirectory?
8576/**
8677 * Sets the package version to 0.0.0-placeholder, so as to obviously indicate
8778 * that the version isn't set in the source code version of package.json.
88- * @param srcDirectory The directory of the source code behind the package, if different.
79+ * @param srcDirectory The directory of the source code behind the package, if different.
8980 */
9081export async function resetPackageVersionPlaceholder ( srcDirectory ?: string ) {
9182 srcDirectory = srcDirectory || '.' ;
0 commit comments