From 10b83b950fd5ff9c6e7c97333b5bca608c7958e0 Mon Sep 17 00:00:00 2001 From: Jason Perkins Date: Wed, 13 Apr 2016 18:55:44 -0400 Subject: [PATCH] Only output NuGet project element if packages were listed by the project --- src/actions/vstudio/vs2010_vcxproj.lua | 18 ++++++++++-------- .../vc2010/test_ensure_nuget_imports.lua | 11 +++++++++++ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/actions/vstudio/vs2010_vcxproj.lua b/src/actions/vstudio/vs2010_vcxproj.lua index c4d42a50..09759b54 100644 --- a/src/actions/vstudio/vs2010_vcxproj.lua +++ b/src/actions/vstudio/vs2010_vcxproj.lua @@ -1434,16 +1434,18 @@ function m.ensureNuGetPackageBuildImports(prj) - p.push('') - p.push('') - p.x('This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.') - p.pop('') + if #prj.nuget > 0 then + p.push('') + p.push('') + p.x('This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.') + p.pop('') - for i = 1, #prj.nuget do - local targetsFile = nuGetTargetsFile(prj, prj.nuget[i]) - p.x('', targetsFile, targetsFile) + for i = 1, #prj.nuget do + local targetsFile = nuGetTargetsFile(prj, prj.nuget[i]) + p.x('', targetsFile, targetsFile) + end + p.pop('') end - p.pop('') end diff --git a/tests/actions/vstudio/vc2010/test_ensure_nuget_imports.lua b/tests/actions/vstudio/vc2010/test_ensure_nuget_imports.lua index 2c747fec..d691a92d 100644 --- a/tests/actions/vstudio/vc2010/test_ensure_nuget_imports.lua +++ b/tests/actions/vstudio/vc2010/test_ensure_nuget_imports.lua @@ -26,6 +26,17 @@ end +-- +-- Should not output anything if no packages have been set. +-- + + function suite.noOutputIfNoPackages() + prepare() + test.isemptycapture() + end + + + -- -- Writes the pre-build check that makes sure that all packages are installed. --