Merge pull request #1723 from cicanci/feature/vs-item-group-condition

This commit is contained in:
starkos 2021-10-20 16:55:20 -06:00
commit 50051b9589
2 changed files with 144 additions and 25 deletions

View File

@ -35,7 +35,9 @@
function suite.emptyGroup_onNoLinks() function suite.emptyGroup_onNoLinks()
prepare() prepare()
test.capture [[ test.capture [[
<ItemGroup> <ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
</ItemGroup> </ItemGroup>
]] ]]
end end
@ -49,7 +51,10 @@
links { "System" } links { "System" }
prepare() prepare()
test.capture [[ test.capture [[
<ItemGroup> <ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<Reference Include="System" />
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Reference Include="System" /> <Reference Include="System" />
</ItemGroup> </ItemGroup>
]] ]]
@ -64,7 +69,12 @@
links { "../Libraries/nunit.framework" } links { "../Libraries/nunit.framework" }
prepare() prepare()
test.capture [[ 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"> <Reference Include="nunit.framework">
<HintPath>..\Libraries\nunit.framework.dll</HintPath> <HintPath>..\Libraries\nunit.framework.dll</HintPath>
</Reference> </Reference>
@ -82,10 +92,37 @@
links { "%{path.getdirectory(os.getcwd())}/Libraries/nunit.framework" } links { "%{path.getdirectory(os.getcwd())}/Libraries/nunit.framework" }
prepare() prepare()
test.capture [[ test.capture [[
<ItemGroup> <ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<Reference Include="nunit.framework"> <Reference Include="nunit.framework">
<HintPath>..\Libraries\nunit.framework.dll</HintPath> <HintPath>..\Libraries\nunit.framework.dll</HintPath>
</Reference> </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> </ItemGroup>
]] ]]
end end
@ -101,7 +138,13 @@
flags { "NoCopyLocal" } flags { "NoCopyLocal" }
prepare() prepare()
test.capture [[ 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"> <Reference Include="nunit.framework">
<HintPath>..\Libraries\nunit.framework.dll</HintPath> <HintPath>..\Libraries\nunit.framework.dll</HintPath>
<Private>False</Private> <Private>False</Private>
@ -121,7 +164,13 @@
copylocal { "SomeOtherProject" } copylocal { "SomeOtherProject" }
prepare() prepare()
test.capture [[ 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"> <Reference Include="nunit.framework">
<HintPath>..\Libraries\nunit.framework.dll</HintPath> <HintPath>..\Libraries\nunit.framework.dll</HintPath>
<Private>False</Private> <Private>False</Private>
@ -135,7 +184,12 @@
copylocal { "../Libraries/nunit.framework" } copylocal { "../Libraries/nunit.framework" }
prepare() prepare()
test.capture [[ 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"> <Reference Include="nunit.framework">
<HintPath>..\Libraries\nunit.framework.dll</HintPath> <HintPath>..\Libraries\nunit.framework.dll</HintPath>
</Reference> </Reference>
@ -154,7 +208,13 @@ if _OPTIONS["test-all"] then
nuget { "Newtonsoft.Json:10.0.2" } nuget { "Newtonsoft.Json:10.0.2" }
prepare() prepare()
test.capture [[ 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"> <Reference Include="Newtonsoft.Json">
<HintPath>packages\Newtonsoft.Json.10.0.2\lib\net45\Newtonsoft.Json.dll</HintPath> <HintPath>packages\Newtonsoft.Json.10.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private> <Private>True</Private>
@ -168,7 +228,13 @@ if _OPTIONS["test-all"] then
nuget { "Newtonsoft.Json:10.0.2" } nuget { "Newtonsoft.Json:10.0.2" }
prepare() prepare()
test.capture [[ 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"> <Reference Include="Newtonsoft.Json">
<HintPath>packages\Newtonsoft.Json.10.0.2\lib\net20\Newtonsoft.Json.dll</HintPath> <HintPath>packages\Newtonsoft.Json.10.0.2\lib\net20\Newtonsoft.Json.dll</HintPath>
<Private>True</Private> <Private>True</Private>
@ -190,7 +256,17 @@ if _OPTIONS["test-all"] then
nuget { "NUnit:3.6.1" } nuget { "NUnit:3.6.1" }
prepare() prepare()
test.capture [[ 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"> <Reference Include="nunit.framework">
<HintPath>packages\NUnit.3.6.1\lib\net20\nunit.framework.dll</HintPath> <HintPath>packages\NUnit.3.6.1\lib\net20\nunit.framework.dll</HintPath>
<Private>True</Private> <Private>True</Private>
@ -216,7 +292,17 @@ if _OPTIONS["test-all"] then
flags { "NoCopyLocal" } flags { "NoCopyLocal" }
prepare() prepare()
test.capture [[ 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"> <Reference Include="nunit.framework">
<HintPath>packages\NUnit.3.6.1\lib\net20\nunit.framework.dll</HintPath> <HintPath>packages\NUnit.3.6.1\lib\net20\nunit.framework.dll</HintPath>
<Private>False</Private> <Private>False</Private>
@ -235,7 +321,17 @@ if _OPTIONS["test-all"] then
copylocal { "SomeOtherProject" } copylocal { "SomeOtherProject" }
prepare() prepare()
test.capture [[ 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"> <Reference Include="nunit.framework">
<HintPath>packages\NUnit.3.6.1\lib\net20\nunit.framework.dll</HintPath> <HintPath>packages\NUnit.3.6.1\lib\net20\nunit.framework.dll</HintPath>
<Private>False</Private> <Private>False</Private>
@ -254,7 +350,17 @@ if _OPTIONS["test-all"] then
copylocal { "NUnit:3.6.1" } copylocal { "NUnit:3.6.1" }
prepare() prepare()
test.capture [[ 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"> <Reference Include="nunit.framework">
<HintPath>packages\NUnit.3.6.1\lib\net20\nunit.framework.dll</HintPath> <HintPath>packages\NUnit.3.6.1\lib\net20\nunit.framework.dll</HintPath>
<Private>True</Private> <Private>True</Private>
@ -280,7 +386,21 @@ if _OPTIONS["test-all"] then
nuget { "MetroModernUI:1.4.0" } nuget { "MetroModernUI:1.4.0" }
prepare() prepare()
test.capture [[ 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"> <Reference Include="MetroFramework.Design">
<HintPath>packages\MetroModernUI.1.4.0.0\lib\net\MetroFramework.Design.dll</HintPath> <HintPath>packages\MetroModernUI.1.4.0.0\lib\net\MetroFramework.Design.dll</HintPath>
<Private>True</Private> <Private>True</Private>

View File

@ -328,7 +328,7 @@
-- Write out the references item group. -- Write out the references item group.
-- --
dotnetbase.elements.references = function(prj) dotnetbase.elements.references = function(cfg)
return { return {
dotnetbase.assemblyReferences, dotnetbase.assemblyReferences,
dotnetbase.nuGetReferences, dotnetbase.nuGetReferences,
@ -336,21 +336,20 @@
end end
function dotnetbase.references(prj) function dotnetbase.references(prj)
_p(1,'<ItemGroup>') for cfg in project.eachconfig(prj) do
p.callArray(dotnetbase.elements.references, prj) _p(1,'<ItemGroup %s>', dotnetbase.condition(cfg))
p.callArray(dotnetbase.elements.references, cfg)
_p(1,'</ItemGroup>') _p(1,'</ItemGroup>')
end end
end
-- --
-- Write the list of assembly (system, or non-sibling) references. -- Write the list of assembly (system, or non-sibling) references.
-- --
function dotnetbase.assemblyReferences(prj) function dotnetbase.assemblyReferences(cfg)
-- C# doesn't support per-configuration links (does it?) so just use local prj = cfg.project
-- the settings from the first available config instead
local cfg = project.getfirstconfig(prj)
config.getlinks(cfg, "system", function(original, decorated) config.getlinks(cfg, "system", function(original, decorated)
local name = path.getname(decorated) local name = path.getname(decorated)
if path.getextension(name) == ".dll" then if path.getextension(name) == ".dll" then
@ -421,13 +420,13 @@
-- Write the list of NuGet references. -- 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 if _ACTION >= "vs2010" and not vstudio.nuget2010.supportsPackageReferences(prj) then
for _, package in ipairs(prj.nuget) do for _, package in ipairs(prj.nuget) do
local id = vstudio.nuget2010.packageId(package) local id = vstudio.nuget2010.packageId(package)
local packageAPIInfo = vstudio.nuget2010.packageAPIInfo(prj, package) local packageAPIInfo = vstudio.nuget2010.packageAPIInfo(prj, package)
local cfg = p.project.getfirstconfig(prj)
local action = p.action.current() local action = p.action.current()
local targetFramework = cfg.dotnetframework or action.vstudio.targetFramework local targetFramework = cfg.dotnetframework or action.vstudio.targetFramework