Skip to content

Commit 2de7d8a

Browse files
committed
Use TargetFrameworks tag if multiple frameworks are provided by dotnetframework
1 parent 55fc4b2 commit 2de7d8a

5 files changed

Lines changed: 140 additions & 80 deletions

File tree

modules/vstudio/tests/cs2005/test_netcore.lua

Lines changed: 80 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -18,132 +18,132 @@ local project = p.project
1818
local wks, prj
1919

2020
function suite.setup()
21-
p.action.set("vs2005")
22-
wks, prj = test.createWorkspace()
21+
p.action.set("vs2005")
22+
wks, prj = test.createWorkspace()
2323
configurations { "Debug", "Release", "Distribution"}
24-
language "C#"
24+
language "C#"
2525
end
2626

2727
local function targetFrameworkPrepare()
28-
local cfg = test.getconfig(prj, "Debug")
29-
dn2005.netcore.targetFramework(cfg)
28+
local cfg = test.getconfig(prj, "Debug")
29+
dn2005.netcore.targetFramework(cfg)
3030
end
3131

3232
local function targetFrameworkVersionPrepare()
33-
local cfg = test.getconfig(prj, "Debug")
34-
dn2005.targetFrameworkVersion(cfg)
33+
local cfg = test.getconfig(prj, "Debug")
34+
dn2005.targetFrameworkVersion(cfg)
3535
end
3636

3737
local function projectConfigurationsPrepare()
38-
dn2005.projectConfigurations(prj)
38+
dn2005.projectConfigurations(prj)
3939
end
4040

4141
local function prepareNetcore()
42-
dn2005.projectElement(prj)
42+
dn2005.projectElement(prj)
4343
end
4444

4545
local function prepareProjectProperties()
46-
local localProj = test.getproject(wks, 1)
46+
local localProj = test.getproject(wks, 1)
4747

48-
dn2005.prepare(cs2005)
49-
dn2005.projectProperties(localProj)
48+
dn2005.prepare(cs2005)
49+
dn2005.projectProperties(localProj)
5050
end
5151

5252
function suite.targetFrameworkProperty_framework()
53-
dotnetframework "4.7.2"
54-
targetFrameworkPrepare()
55-
test.isemptycapture()
53+
dotnetframework "4.7.2"
54+
targetFrameworkPrepare()
55+
test.isemptycapture()
5656
end
5757

5858
function suite.targetFrameworkProperty_core()
59-
dotnetframework "netcoreapp2.2"
60-
targetFrameworkPrepare()
61-
test.capture [[
59+
dotnetframework "netcoreapp2.2"
60+
targetFrameworkPrepare()
61+
test.capture [[
6262
<TargetFramework>netcoreapp2.2</TargetFramework>
6363
]]
6464
end
6565

6666
function suite.targetFrameworkProperty_standard()
67-
dotnetframework "netstandard1.2"
68-
targetFrameworkPrepare()
69-
test.capture [[
67+
dotnetframework "netstandard1.2"
68+
targetFrameworkPrepare()
69+
test.capture [[
7070
<TargetFramework>netstandard1.2</TargetFramework>
71-
]]
71+
]]
7272
end
7373

7474
function suite.targetFrameworkVersionProperty_framework()
75-
dotnetframework "4.7.2"
76-
targetFrameworkVersionPrepare()
77-
test.capture [[
75+
dotnetframework "4.7.2"
76+
targetFrameworkVersionPrepare()
77+
test.capture [[
7878
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
79-
]]
79+
]]
8080
end
8181

8282
function suite.targetFrameworkVersionProperty_core()
83-
dotnetframework "netcoreapp2.2"
84-
targetFrameworkVersionPrepare()
85-
test.isemptycapture()
83+
dotnetframework "netcoreapp2.2"
84+
targetFrameworkVersionPrepare()
85+
test.isemptycapture()
8686
end
8787

8888
function suite.targetFrameworkVersionProperty_standard()
89-
dotnetframework "netstandard1.2"
90-
targetFrameworkVersionPrepare()
91-
test.isemptycapture()
89+
dotnetframework "netstandard1.2"
90+
targetFrameworkVersionPrepare()
91+
test.isemptycapture()
9292
end
9393

9494
function suite.project_element_standard()
95-
dotnetframework "netstandard1.2"
96-
prepareNetcore()
97-
test.capture [[
95+
dotnetframework "netstandard1.2"
96+
prepareNetcore()
97+
test.capture [[
9898
<Project Sdk="Microsoft.NET.Sdk">
99-
]]
99+
]]
100100
end
101101

102102
function suite.project_element_core()
103-
dotnetframework "netcoreapp1.2"
104-
prepareNetcore()
105-
test.capture [[
103+
dotnetframework "netcoreapp1.2"
104+
prepareNetcore()
105+
test.capture [[
106106
<Project Sdk="Microsoft.NET.Sdk">
107-
]]
107+
]]
108108
end
109109

110110
function suite.project_element_net5()
111-
dotnetframework "net5.0"
112-
prepareNetcore()
113-
test.capture [[
111+
dotnetframework "net5.0"
112+
prepareNetcore()
113+
test.capture [[
114114
<Project Sdk="Microsoft.NET.Sdk">
115-
]]
115+
]]
116116
end
117117

118118
function suite.project_element_framework()
119-
dotnetframework "4.7.2"
120-
prepareNetcore()
121-
test.capture [[
119+
dotnetframework "4.7.2"
120+
prepareNetcore()
121+
test.capture [[
122122
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
123-
]]
123+
]]
124124
end
125125

126126
function suite.allowUnsafeProperty_core()
127-
dotnetframework "netcoreapp2.2"
128-
clr "Unsafe"
129-
prepareProjectProperties()
130-
test.capture [[
127+
dotnetframework "netcoreapp2.2"
128+
clr "Unsafe"
129+
prepareProjectProperties()
130+
test.capture [[
131131
<PropertyGroup>
132132
<OutputType>Exe</OutputType>
133133
<AppDesignerFolder>Properties</AppDesignerFolder>
134134
<TargetFramework>netcoreapp2.2</TargetFramework>
135135
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
136136
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
137137
</PropertyGroup>
138-
]]
138+
]]
139139
end
140140

141141
function suite.implicitUsings_on()
142-
p.action.set("vs2022")
143-
dotnetframework "net10.0"
144-
enableimplicitusings "On"
145-
prepareProjectProperties()
146-
test.capture [[
142+
p.action.set("vs2022")
143+
dotnetframework "net10.0"
144+
enableimplicitusings "On"
145+
prepareProjectProperties()
146+
test.capture [[
147147
<PropertyGroup>
148148
<OutputType>Exe</OutputType>
149149
<AppDesignerFolder>Properties</AppDesignerFolder>
@@ -152,15 +152,15 @@ function suite.implicitUsings_on()
152152
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
153153
<ImplicitUsings>true</ImplicitUsings>
154154
</PropertyGroup>
155-
]]
155+
]]
156156
end
157157

158158
function suite.implicitUsings_off()
159-
p.action.set("vs2022")
160-
dotnetframework "net10.0"
161-
enableimplicitusings "Off"
162-
prepareProjectProperties()
163-
test.capture [[
159+
p.action.set("vs2022")
160+
dotnetframework "net10.0"
161+
enableimplicitusings "Off"
162+
prepareProjectProperties()
163+
test.capture [[
164164
<PropertyGroup>
165165
<OutputType>Exe</OutputType>
166166
<AppDesignerFolder>Properties</AppDesignerFolder>
@@ -169,7 +169,22 @@ function suite.implicitUsings_off()
169169
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
170170
<ImplicitUsings>false</ImplicitUsings>
171171
</PropertyGroup>
172-
]]
172+
]]
173+
end
174+
175+
function suite.multiple_target_dotnet_frameworks()
176+
p.action.set("vs2022")
177+
dotnetframework "net8.0;net10.0"
178+
prepareProjectProperties()
179+
test.capture [[
180+
<PropertyGroup>
181+
<OutputType>Exe</OutputType>
182+
<AppDesignerFolder>Properties</AppDesignerFolder>
183+
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
184+
<Configurations>Debug;Release;Distribution</Configurations>
185+
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
186+
</PropertyGroup>
187+
]]
173188
end
174189

175190
function suite.project_element_configurations()

modules/vstudio/tests/vc2010/test_globals.lua

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,21 @@ function suite.frameworkVersionIsCorrectNetCore_onSpecificVersion()
111111
]]
112112
end
113113

114+
function suite.frameworkVersionIsCorrectNetCore_onSpecificVersions()
115+
clr "NetCore"
116+
dotnetframework "net8.0;net10.0"
117+
prepare()
118+
test.capture [[
119+
<PropertyGroup Label="Globals">
120+
<ProjectGuid>{42B5DBC6-AE1F-903D-F75D-41E363076E92}</ProjectGuid>
121+
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
122+
<Keyword>ManagedCProj</Keyword>
123+
<RootNamespace>MyProject</RootNamespace>
124+
</PropertyGroup>
125+
]]
126+
end
127+
128+
114129
--
115130
-- Omit Keyword and RootNamespace for non-Windows projects.
116131
--

modules/vstudio/vs2005_dotnetbase.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,11 @@
809809
local action = p.action.current()
810810
local framework = cfg.dotnetframework or action.vstudio.targetFramework
811811
if framework and dotnetbase.isNewFormatProject(cfg) then
812-
_p(2,'<TargetFramework>%s</TargetFramework>', framework)
812+
if string.match(framework, ";") then
813+
_p(2,'<TargetFrameworks>%s</TargetFrameworks>', framework)
814+
else
815+
_p(2,'<TargetFramework>%s</TargetFramework>', framework)
816+
end
813817
end
814818
end
815819

modules/vstudio/vs2010_vcxproj.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,12 @@
118118

119119
local framework = prj.dotnetframework or action.vstudio.targetFramework or "4.0"
120120
if framework and dotnetbase.isNewFormatProject(prj) then
121-
p.w('<TargetFramework>%s</TargetFramework>', framework)
121+
if string.match(framework, ";") then
122+
p.w('<TargetFrameworks>%s</TargetFrameworks>', framework)
123+
else
124+
p.w('<TargetFramework>%s</TargetFramework>', framework)
125+
end
126+
122127
else
123128
p.w('<TargetFrameworkVersion>v%s</TargetFrameworkVersion>', framework)
124129
end

website/docs/dotnetframework.md

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
1-
Selects a .NET framework version.
1+
Selects a .NET framework version(s).
22

33
```lua
4-
dotnetframework ("version")
4+
dotnetframework ("versions")
55
```
66

77
This value currently is only applied to Visual Studio 2005 or later, and GNU makefiles using Mono. If no .NET framework version is specified the toolset default is used.
88

99
### Parameters ###
1010

11-
`version` is one of:
11+
`versions` is a semicolon separated list of version numbers where each element is one of:
1212

1313
| Version | Documentation |
14-
| 1.0 | .NET Framework 1.0 |
15-
| 1.1 | .NET Framework 1.1 |
16-
| 2.0 | .NET Framework 2.0 |
17-
| 3.0 | .NET Framework 3.0 |
18-
| 3.5 | .NET Framework 3.5 |
19-
| 4.0 | .NET Framework 4.0 |
20-
| 4.5 | .NET Framework 4.5 |
21-
| 4.6 | .NET Framework 4.6 |
14+
| X.X | .NET Framework X.X |
15+
| netcoreappX.X | .NET Core X.X |
16+
| netstandardX.X | .NET Standard X.X |
17+
| netX.X | .NET X.X |
2218

2319
### Applies To ###
2420

@@ -30,10 +26,35 @@ Premake 5.0.0-alpha1 or later.
3026

3127
### Examples ###
3228

33-
Use the .NET framework 3.0.
29+
Use .NET 10.0:
3430

3531
```lua
36-
dotnetframework "3.0"
32+
dotnetframework "net10.0"
33+
```
34+
35+
Use .NET 8.0 and .NET 10.0:
36+
37+
```lua
38+
dotnetframework "net8.0;net10.0"
39+
```
40+
41+
Use .NET Core 2.1:
42+
43+
```lua
44+
dotnetframework "netcoreapp2.1"
45+
```
46+
47+
Use .NET Standard 2.1:
48+
49+
```lua
50+
dotnetframework "netstandard2.1"
51+
```
52+
53+
54+
Use the .NET framework 4.6:
55+
56+
```lua
57+
dotnetframework "4.6"
3758
```
3859

3960
### See Also ###

0 commit comments

Comments
 (0)