diff --git a/src/actions/vstudio/vs2005.lua b/src/actions/vstudio/vs2005.lua
index 7b18389b..244a310d 100644
--- a/src/actions/vstudio/vs2005.lua
+++ b/src/actions/vstudio/vs2005.lua
@@ -34,7 +34,12 @@
premake.generate(prj, ".csproj.user", vstudio.cs2005.generateUser)
elseif premake.project.iscpp(prj) then
premake.generate(prj, ".vcproj", vstudio.vc200x.generate)
- premake.generate(prj, ".vcproj.user", vstudio.vc200x.generateUser)
+
+ -- Skip generation of empty user files
+ local user = p.capture(function() vstudio.vc200x.generateUser(prj) end)
+ if #user > 0 then
+ p.generate(prj, ".vcproj.user", function() p.out(user) end)
+ end
end
end
diff --git a/src/actions/vstudio/vs200x_vcproj_user.lua b/src/actions/vstudio/vs200x_vcproj_user.lua
index 201b3cbe..be12e605 100644
--- a/src/actions/vstudio/vs200x_vcproj_user.lua
+++ b/src/actions/vstudio/vs200x_vcproj_user.lua
@@ -21,18 +21,38 @@
function m.generateUser(prj)
p.indent("\t")
- m.xmlElement()
- m.visualStudioUserFile()
- p.push('')
+ -- Only want output if there is something to configure
+ local contents = {}
+ local generate = false
+
for cfg in p.project.eachconfig(prj) do
- m.userConfiguration(cfg)
- p.callArray(m.elements.user, cfg)
- p.pop('')
+ contents[cfg] = p.capture(function()
+ p.push(4)
+ p.callArray(m.elements.user, cfg)
+ p.pop(4)
+ end)
+ if #contents[cfg] > 0 then
+ generate = true
+ end
end
- p.pop('')
- p.pop('')
+ if generate then
+ m.xmlElement()
+ m.visualStudioUserFile()
+ p.push('')
+ for cfg in p.project.eachconfig(prj) do
+ m.userConfiguration(cfg)
+ p.push(' 0 then
+ p.outln(contents[cfg])
+ end
+ p.pop('/>')
+ p.pop('')
+ end
+ p.pop('')
+ p.pop('')
+ end
end
@@ -78,9 +98,7 @@
end
function m.debugSettings(cfg)
- p.push('')
end
diff --git a/tests/_tests.lua b/tests/_tests.lua
index 6e9702c8..4255dad1 100644
--- a/tests/_tests.lua
+++ b/tests/_tests.lua
@@ -92,6 +92,7 @@ return {
"actions/vstudio/vc200x/test_project.lua",
"actions/vstudio/vc200x/test_project_refs.lua",
"actions/vstudio/vc200x/test_resource_compiler.lua",
+ "actions/vstudio/vc200x/test_user_file.lua",
-- Visual Studio 2010 C/C++ projects
"actions/vstudio/vc2010/test_assembly_refs.lua",
@@ -116,9 +117,9 @@ return {
"actions/vstudio/vc2010/test_project_configs.lua",
"actions/vstudio/vc2010/test_project_refs.lua",
"actions/vstudio/vc2010/test_prop_sheet.lua",
- "actions/vstudio/vc2010/test_user_file.lua",
"actions/vstudio/vc2010/test_resource_compile.lua",
"actions/vstudio/vc2010/test_rule_vars.lua",
+ "actions/vstudio/vc2010/test_user_file.lua",
-- Makefile tests
"actions/make/test_make_escaping.lua",
diff --git a/tests/actions/vstudio/vc200x/test_debug_settings.lua b/tests/actions/vstudio/vc200x/test_debug_settings.lua
index fc2a4560..6cc0bf1f 100644
--- a/tests/actions/vstudio/vc200x/test_debug_settings.lua
+++ b/tests/actions/vstudio/vc200x/test_debug_settings.lua
@@ -32,10 +32,7 @@
function suite.emptyBlock_onNoSettings()
prepare()
- test.capture [[
-
- ]]
+ test.isemptycapture()
end
@@ -49,9 +46,7 @@
debugcommand "bin/emulator.exe"
prepare()
test.capture [[
-
+Command="..\bin\emulator.exe"
]]
end
@@ -66,9 +61,7 @@
debugdir "bin/debug"
prepare()
test.capture [[
-
+WorkingDirectory="..\bin\debug"
]]
end
@@ -81,9 +74,7 @@
debugargs { "arg1", "arg2" }
prepare()
test.capture [[
-
+CommandArguments="arg1 arg2"
]]
end
@@ -96,9 +87,7 @@
debugenvs { "key=value" }
prepare()
test.capture [[
-
+Environment="key=value"
]]
end
@@ -111,9 +100,7 @@
debugenvs { 'key="value"' }
prepare()
test.capture [[
-
+Environment="key="value""
]]
end
@@ -127,9 +114,7 @@
debugenvs { "key=value", "foo=bar" }
prepare()
test.capture [[
-
+Environment="key=value
foo=bar"
]]
end
@@ -144,9 +129,7 @@
flags { "DebugEnvsDontMerge" }
prepare()
test.capture [[
-
+Environment="key=value"
+EnvironmentMerge="false"
]]
end
diff --git a/tests/actions/vstudio/vc200x/test_user_file.lua b/tests/actions/vstudio/vc200x/test_user_file.lua
new file mode 100644
index 00000000..0808f57f
--- /dev/null
+++ b/tests/actions/vstudio/vc200x/test_user_file.lua
@@ -0,0 +1,49 @@
+--
+-- tests/actions/vstudio/vc200x/test_user_file.lua
+-- Verify handling of empty and non-empty .user files for VC'200x.
+-- Copyright (c) 2015 Jason Perkins and the Premake project
+--
+
+ local suite = test.declare("vstudio_vs200x_user_file")
+ local vc200x = premake.vstudio.vc200x
+ local project = premake.project
+
+
+--
+-- Setup
+--
+
+ local sln
+
+ function suite.setup()
+ _ACTION = "vs2008"
+ sln = test.createsolution()
+ end
+
+ local function prepare()
+ local prj = test.getproject(sln, 1)
+ vc200x.generateUser(prj)
+ end
+
+
+--
+-- If no debugger settings have been specified, then the .user
+-- file should not be written at all.
+--
+
+ function suite.noOutput_onNoSettings()
+ prepare()
+ test.isemptycapture()
+ end
+
+
+--
+-- If a debugger setting has been specified, output.
+--
+
+ function suite.doesOutput_onDebugSettings()
+ debugcommand "bin/emulator.exe"
+ prepare()
+ test.hasoutput()
+ end
+