我们正在使用TFS 2015并尝试使用NPM和JSPM构建网站项目。 在开发过程中,我们一直在运行" npm install"和" jspm安装"在添加新包等时从命令行,这已经工作正常。 我现在正试图在TFS上建立项目。 我尝试将以下内容添加到.csproj中:
<Target Name="AfterBuild">
<Exec Command="attrib -r .dependencies.json" WorkingDirectory=".\jspm_packages" />
<Exec Command="attrib -r jspm.config.js" WorkingDirectory="." />
<Exec Command="attrib -r package.json" WorkingDirectory="." />
<Exec Command=".bin\npm install" WorkingDirectory="." />
<Exec Command=".bin\jspm install -y" WorkingDirectory="." />
<Exec Command=".bin\node build.js --minify --sourceMaps" Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'" WorkingDirectory="." />
</Target>
并且,作为单独尝试使其工作,我尝试创建.cmd文件(tfsbuild.cmd):
attrib -r "jspm_packages\.dependencies.json"
attrib -r "jspm.config.js"
attrib -r "package.json"
call .bin\npm install > _npm.log
call .bin\jspm install -y > _jspm.log
call .bin\node build.js --minify --sourceMaps > _nodebuild.log
并从.csproj
调用它<Exec Command="tfsbuild.cmd" Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'" WorkingDirectory="." />
我尝试的所有构建都失败了,说jspm install命令退出代码1.请注意,我将命令的输出提供给.log文件以帮助理解问题。 如果我直接从.csproj文件在TFS构建机器上运行的文件夹中运行tfsbuild.cmd,那么一切正常,并且jspm.log文件输出预期的响应:(截断)
Creating registry cache...
ok jquery.ui.position to npm:jquery.ui.position@^1.11.4 (1.11.4)
ok respond.js to npm:respond.js@^1.4.2 (1.4.2)
ok jquery2 to npm:jquery@2.2.4 (2.2.4)
ok jquery1 to npm:jquery@1.12.3 (1.12.3)
ok modernizr to github:Modernizr/Modernizr@2.6.2 (2.6.2)
ok bootstrap-datetimepicker to github:smalot/bootstrap-datetimepicker@2.3.9 (2.3.9)
ok js-xlsxActual to github:sheetjs/js-xlsx@0.8.0 (0.8.0)
ok rangy to github:timdown/rangy-release@^1.3.0 (1.3.0)
ok jquery-validation to github:jquery-validation/jquery-validation@1.8.1 (jzaefferer/jquery-validation@1.8.1)
ok jquery-validation-unobtrusive to github:aspnet/jquery-validation-unobtrusive@3.2.2 (3.2.2)
ok knockout to github:knockout/knockout@3.4.0 (3.4.0)
ok Installed peer jsbn to npm:jsbn@0.1 (0.1.1)
ok Installed npm:tweetnacl@^0.14.3 (0.14.5)
ok Installed npm:chartjs-color@^2.0.0 (2.1.0)
ok Installed npm:get-stdin@^4.0.1 (4.0.1)
ok Installed npm:glob@^7.0.3 (7.1.1)
ok Installed npm:lodash.mergewith@^4.6.0 (4.6.0)
ok Installed npm:meow@^3.7.0 (3.7.0)
ok Installed npm:lodash.clonedeep@^4.3.2 (4.5.0)
ok Installed npm:npmlog@^4.0.0 (4.0.2)
ok Installed npm:in-publish@^2.0.0 (2.0.0)
ok Installed npm:cross-spawn@^3.0.0 (3.0.1)
ok Installed npm:async-foreach@^0.1.3 (0.1.3)
ok Installed npm:gaze@^1.0.0 (1.1.2)
...
但是,从构建过程调用tfsbuild.cmd时,输出到jspm.log的情况非常不同,并且将代码1返回给msbuild,因此构建失败。 (整个文件)
Downloading npm:font-awesome@4.7.0
Downloading npm:jquery@2.2.4
Downloading npm:jquery@1.12.3
Downloading npm:respond.js@1.4.2
Downloading npm:emojione@2.2.7
Downloading npm:jquery.ui.position@1.11.4
warn Installation changes not saved.
我很困惑,为什么从msbuild运行时命令的行为会有所不同。任何帮助将非常感激。谢谢。