Skip to content

Commit 1338f3a

Browse files
author
Beernaert Robbe
committed
the desired flow for global.json is working but the test is not working due to using p.generate twice!
1 parent 0243b80 commit 1338f3a

File tree

2 files changed

+37
-13
lines changed

2 files changed

+37
-13
lines changed

modules/vstudio/tests/cs2005/test_dotnetsdk.lua

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,5 +140,25 @@
140140
}
141141
}
142142
]]
143+
end
143144

145+
function suite.testMSTestGlobalJSONExists()
146+
prepare()
147+
local cfg = test.getconfig(prj, "Debug")
148+
prj.dotnetsdk = "MSTest"
149+
p.generate(prj,path.join(prj.workspace.location, "global.json"), function() p.outln([[
150+
{
151+
"test:"testing"
152+
}
153+
]]) end)
154+
dn2005.output_global_json(prj)
155+
test.capture[[
156+
{
157+
"test:"testing",
158+
"msbuild-sdks":
159+
{
160+
"MSTest.Sdk": "3.6.1"
161+
}
162+
}
163+
]]
144164
end

modules/vstudio/vs2005_dotnetbase.lua

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -845,20 +845,24 @@
845845
end
846846

847847
function dotnetbase.output_global_json(prj) -- unsure how you handle project with different config
848-
if prj.dotnetsdk == "MSTest" then
849-
_p([[
850-
{
851-
"msbuild-sdks":
852-
{
853-
"MSTest.Sdk": "3.6.1"
854-
}
855-
}
856-
]])
848+
if prj.dotnetsdk == "MSTest" then
849+
globaljson = json.decode(io.readfile(path.join(prj.workspace.location, "global.json")))
850+
if globaljson == nil then
851+
globaljson = {}
852+
globaljson["msbuild-sdks"] = {}
853+
globaljson["msbuild-sdks"]["MSTest.Sdk"] = "3.6.1"
854+
elseif globaljson["msbuild-sdks"] ~= nil then
855+
globaljson["msbuild-sdks"]["MSTest.Sdk"] = "3.6.1"
856+
else
857+
globaljson["msbuild-sdks"] = {}
858+
globaljson["msbuild-sdks"]["MSTest.Sdk"] = "3.6.1"
859+
end
860+
_p(json.encode(globaljson))
857861
end
858862
end
859863
function dotnetbase.generate_global_json(prj)
860-
local content = p.capture(function() dotnetbase.output_global_json(prj) end)
861-
if content ~= nil and #content > 0 then
862-
p.generate(prj, path.join(prj.workspace.location,"global.json"), function() p.outln(content) end)
863-
end
864+
local content = p.capture(function() dotnetbase.output_global_json(prj) end)
865+
if content ~= nil and #content > 0 then
866+
p.generate(prj, path.join(prj.workspace.location, "global.json"), function() p.outln(content) end)
867+
end
864868
end

0 commit comments

Comments
 (0)