Skip to content

Commit

Permalink
Added conditional to VS ItemGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
cicanci committed Oct 18, 2021
1 parent 1c13046 commit cd276f8
Show file tree
Hide file tree
Showing 2 changed files with 144 additions and 25 deletions.
148 changes: 134 additions & 14 deletions modules/vstudio/tests/cs2005/test_assembly_refs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
function suite.emptyGroup_onNoLinks()
prepare()
test.capture [[
<ItemGroup>
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
</ItemGroup>
]]
end
Expand All @@ -49,7 +51,10 @@
links { "System" }
prepare()
test.capture [[
<ItemGroup>
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<Reference Include="System" />
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Reference Include="System" />
</ItemGroup>
]]
Expand All @@ -64,7 +69,12 @@
links { "../Libraries/nunit.framework" }
prepare()
test.capture [[
<ItemGroup>
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<Reference Include="nunit.framework">
<HintPath>..\Libraries\nunit.framework.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Reference Include="nunit.framework">
<HintPath>..\Libraries\nunit.framework.dll</HintPath>
</Reference>
Expand All @@ -82,10 +92,37 @@
links { "%{path.getdirectory(os.getcwd())}/Libraries/nunit.framework" }
prepare()
test.capture [[
<ItemGroup>
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<Reference Include="nunit.framework">
<HintPath>..\Libraries\nunit.framework.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Reference Include="nunit.framework">
<HintPath>..\Libraries\nunit.framework.dll</HintPath>
</Reference>
</ItemGroup>
]]
end


--
-- Add configuration condition to VS csproj references ItemGroup
--

function suite.assemblyRef_onConfigurationCondition()
links { "%{path.getdirectory(os.getcwd())}/Libraries/%{cfg.buildcfg}/nunit.framework" }
prepare()
test.capture [[
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<Reference Include="nunit.framework">
<HintPath>..\Libraries\Debug\nunit.framework.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Reference Include="nunit.framework">
<HintPath>..\Libraries\Release\nunit.framework.dll</HintPath>
</Reference>
</ItemGroup>
]]
end
Expand All @@ -101,7 +138,13 @@
flags { "NoCopyLocal" }
prepare()
test.capture [[
<ItemGroup>
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<Reference Include="nunit.framework">
<HintPath>..\Libraries\nunit.framework.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Reference Include="nunit.framework">
<HintPath>..\Libraries\nunit.framework.dll</HintPath>
<Private>False</Private>
Expand All @@ -121,7 +164,13 @@
copylocal { "SomeOtherProject" }
prepare()
test.capture [[
<ItemGroup>
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<Reference Include="nunit.framework">
<HintPath>..\Libraries\nunit.framework.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Reference Include="nunit.framework">
<HintPath>..\Libraries\nunit.framework.dll</HintPath>
<Private>False</Private>
Expand All @@ -135,7 +184,12 @@
copylocal { "../Libraries/nunit.framework" }
prepare()
test.capture [[
<ItemGroup>
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<Reference Include="nunit.framework">
<HintPath>..\Libraries\nunit.framework.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Reference Include="nunit.framework">
<HintPath>..\Libraries\nunit.framework.dll</HintPath>
</Reference>
Expand All @@ -154,7 +208,13 @@ if _OPTIONS["test-all"] then
nuget { "Newtonsoft.Json:10.0.2" }
prepare()
test.capture [[
<ItemGroup>
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<Reference Include="Newtonsoft.Json">
<HintPath>packages\Newtonsoft.Json.10.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Reference Include="Newtonsoft.Json">
<HintPath>packages\Newtonsoft.Json.10.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
Expand All @@ -168,7 +228,13 @@ if _OPTIONS["test-all"] then
nuget { "Newtonsoft.Json:10.0.2" }
prepare()
test.capture [[
<ItemGroup>
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<Reference Include="Newtonsoft.Json">
<HintPath>packages\Newtonsoft.Json.10.0.2\lib\net20\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Reference Include="Newtonsoft.Json">
<HintPath>packages\Newtonsoft.Json.10.0.2\lib\net20\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
Expand All @@ -190,7 +256,17 @@ if _OPTIONS["test-all"] then
nuget { "NUnit:3.6.1" }
prepare()
test.capture [[
<ItemGroup>
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<Reference Include="nunit.framework">
<HintPath>packages\NUnit.3.6.1\lib\net20\nunit.framework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NUnit.System.Linq">
<HintPath>packages\NUnit.3.6.1\lib\net20\NUnit.System.Linq.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Reference Include="nunit.framework">
<HintPath>packages\NUnit.3.6.1\lib\net20\nunit.framework.dll</HintPath>
<Private>True</Private>
Expand All @@ -216,7 +292,17 @@ if _OPTIONS["test-all"] then
flags { "NoCopyLocal" }
prepare()
test.capture [[
<ItemGroup>
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<Reference Include="nunit.framework">
<HintPath>packages\NUnit.3.6.1\lib\net20\nunit.framework.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="NUnit.System.Linq">
<HintPath>packages\NUnit.3.6.1\lib\net20\NUnit.System.Linq.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Reference Include="nunit.framework">
<HintPath>packages\NUnit.3.6.1\lib\net20\nunit.framework.dll</HintPath>
<Private>False</Private>
Expand All @@ -235,7 +321,17 @@ if _OPTIONS["test-all"] then
copylocal { "SomeOtherProject" }
prepare()
test.capture [[
<ItemGroup>
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<Reference Include="nunit.framework">
<HintPath>packages\NUnit.3.6.1\lib\net20\nunit.framework.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="NUnit.System.Linq">
<HintPath>packages\NUnit.3.6.1\lib\net20\NUnit.System.Linq.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Reference Include="nunit.framework">
<HintPath>packages\NUnit.3.6.1\lib\net20\nunit.framework.dll</HintPath>
<Private>False</Private>
Expand All @@ -254,7 +350,17 @@ if _OPTIONS["test-all"] then
copylocal { "NUnit:3.6.1" }
prepare()
test.capture [[
<ItemGroup>
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<Reference Include="nunit.framework">
<HintPath>packages\NUnit.3.6.1\lib\net20\nunit.framework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NUnit.System.Linq">
<HintPath>packages\NUnit.3.6.1\lib\net20\NUnit.System.Linq.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Reference Include="nunit.framework">
<HintPath>packages\NUnit.3.6.1\lib\net20\nunit.framework.dll</HintPath>
<Private>True</Private>
Expand All @@ -280,7 +386,21 @@ if _OPTIONS["test-all"] then
nuget { "MetroModernUI:1.4.0" }
prepare()
test.capture [[
<ItemGroup>
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<Reference Include="MetroFramework.Design">
<HintPath>packages\MetroModernUI.1.4.0.0\lib\net\MetroFramework.Design.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MetroFramework">
<HintPath>packages\MetroModernUI.1.4.0.0\lib\net\MetroFramework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MetroFramework.Fonts">
<HintPath>packages\MetroModernUI.1.4.0.0\lib\net\MetroFramework.Fonts.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Reference Include="MetroFramework.Design">
<HintPath>packages\MetroModernUI.1.4.0.0\lib\net\MetroFramework.Design.dll</HintPath>
<Private>True</Private>
Expand Down
21 changes: 10 additions & 11 deletions modules/vstudio/vs2005_dotnetbase.lua
Original file line number Diff line number Diff line change
Expand Up @@ -328,29 +328,28 @@
-- Write out the references item group.
--

dotnetbase.elements.references = function(prj)
dotnetbase.elements.references = function(cfg)
return {
dotnetbase.assemblyReferences,
dotnetbase.nuGetReferences,
}
end

function dotnetbase.references(prj)
_p(1,'<ItemGroup>')
p.callArray(dotnetbase.elements.references, prj)
_p(1,'</ItemGroup>')
for cfg in project.eachconfig(prj) do
_p(1,'<ItemGroup %s>', dotnetbase.condition(cfg))
p.callArray(dotnetbase.elements.references, cfg)
_p(1,'</ItemGroup>')
end
end


--
-- Write the list of assembly (system, or non-sibling) references.
--

function dotnetbase.assemblyReferences(prj)
-- C# doesn't support per-configuration links (does it?) so just use
-- the settings from the first available config instead
local cfg = project.getfirstconfig(prj)

function dotnetbase.assemblyReferences(cfg)
local prj = cfg.project
config.getlinks(cfg, "system", function(original, decorated)
local name = path.getname(decorated)
if path.getextension(name) == ".dll" then
Expand Down Expand Up @@ -421,13 +420,13 @@
-- Write the list of NuGet references.
--

function dotnetbase.nuGetReferences(prj)
function dotnetbase.nuGetReferences(cfg)
local prj = cfg.project
if _ACTION >= "vs2010" and not vstudio.nuget2010.supportsPackageReferences(prj) then
for _, package in ipairs(prj.nuget) do
local id = vstudio.nuget2010.packageId(package)
local packageAPIInfo = vstudio.nuget2010.packageAPIInfo(prj, package)

local cfg = p.project.getfirstconfig(prj)
local action = p.action.current()
local targetFramework = cfg.dotnetframework or action.vstudio.targetFramework

Expand Down

0 comments on commit cd276f8

Please sign in to comment.