From 34a8b7b83b4fac9f034ab5d863cb1a8516dde6cb Mon Sep 17 00:00:00 2001 From: robbe beernaert Date: Thu, 29 Jun 2023 17:49:05 +0200 Subject: [PATCH 01/58] added C# documentationFile feature --- modules/vstudio/vs2005_csproj.lua | 3 ++- modules/vstudio/vs2005_dotnetbase.lua | 12 ++++++++++-- src/_premake_init.lua | 6 ++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/modules/vstudio/vs2005_csproj.lua b/modules/vstudio/vs2005_csproj.lua index 83a6816319..43efdc3021 100644 --- a/modules/vstudio/vs2005_csproj.lua +++ b/modules/vstudio/vs2005_csproj.lua @@ -81,7 +81,8 @@ dotnetbase.debugProps, dotnetbase.outputProps, dotnetbase.compilerProps, - dotnetbase.NoWarn + dotnetbase.NoWarn, + dotnetbase.documentationFile, } end diff --git a/modules/vstudio/vs2005_dotnetbase.lua b/modules/vstudio/vs2005_dotnetbase.lua index e6371c8fca..cc46024b1b 100644 --- a/modules/vstudio/vs2005_dotnetbase.lua +++ b/modules/vstudio/vs2005_dotnetbase.lua @@ -58,7 +58,7 @@ if dotnetbase.isNewFormatProject(prj) then if prj.flags.WPF then _p('') - else + else _p('') end else @@ -754,6 +754,14 @@ end end + function dotnetbase.documentationFile(cfg) + if cfg.documentationFile and cfg.documentationFile ~= "" then + _p(2, string.format('%s\\%s.xml', vstudio.path(cfg, cfg.documentationFile),cfg.project.name)) + else + _p(2, string.format('%s\\%s.xml',vstudio.path(cfg, cfg.targetdir),cfg.project.name)) + end + end + function dotnetbase.isNewFormatProject(cfg) local framework = cfg.dotnetframework if not framework then @@ -789,4 +797,4 @@ if cfg.clr == "Unsafe" then _p(2,'true') end - end \ No newline at end of file + end diff --git a/src/_premake_init.lua b/src/_premake_init.lua index 963fdaa9c5..2a24d94e6d 100644 --- a/src/_premake_init.lua +++ b/src/_premake_init.lua @@ -765,6 +765,12 @@ } } + api.register { + name = "documentationFile", + scope = "project", + kind = "string", + } + api.register { name = "cdialect", scope = "config", From 42128d0f730d427e78903d1557a8e9777e024dfb Mon Sep 17 00:00:00 2001 From: robbe beernaert Date: Thu, 29 Jun 2023 21:03:21 +0200 Subject: [PATCH 02/58] wrote unit tests for C# documentationFile --- modules/vstudio/tests/_tests.lua | 1 + .../tests/cs2005/test_documentation_file.lua | 82 +++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 modules/vstudio/tests/cs2005/test_documentation_file.lua diff --git a/modules/vstudio/tests/_tests.lua b/modules/vstudio/tests/_tests.lua index 07cd658a26..2e6e60c28d 100644 --- a/modules/vstudio/tests/_tests.lua +++ b/modules/vstudio/tests/_tests.lua @@ -13,6 +13,7 @@ return { "cs2005/test_no_warn.lua", "cs2005/test_debug_props.lua", "cs2005/test_debug_props_2019.lua", + "cs2005/test_documentation_file.lua", "cs2005/test_files.lua", "cs2005/test_icon.lua", "cs2005/test_netcore.lua", diff --git a/modules/vstudio/tests/cs2005/test_documentation_file.lua b/modules/vstudio/tests/cs2005/test_documentation_file.lua new file mode 100644 index 0000000000..29de3a2032 --- /dev/null +++ b/modules/vstudio/tests/cs2005/test_documentation_file.lua @@ -0,0 +1,82 @@ +-- +-- tests/actions/vstudio/cs2005/test_debug_props.lua +-- Test debugging and optimization flags block of a Visual Studio 2005+ C# project. +-- Copyright (c) 2012-2013 Jason Perkins and the Premake project +-- + local p = premake + local suite = test.declare("vstudio_cs2005_documentation_file") + local dn2005 = p.vstudio.dotnetbase +-- +-- Setup +-- + + local wks, prj + +-- +-- Setup and teardown +-- + function suite.setup() + p.action.set("vs2010") + wks = test.createWorkspace() + configurations { "Debug", "Release" } + -- project "documentationFile" + language "C#" + targetdir("test\\targetDir") + end + + local function setConfig() + local cfg = test.getconfig(prj, "Debug") + dn2005.documentationFile(cfg); + end + + + + local function prepare() + prj = test.getproject(wks, 1) + end + + + + local function prepareNil() + prepare() + setConfig() + end + + local function prepareEmpty() + prepare() + documentationFile "" + setConfig() + end + + local function prepareDir() + prepare() + documentationFile "test" + setConfig() + end + +-- +-- Test Eempty and Nil +-- + +function suite.documentationFileNil() + prepareNil() + test.capture([[ + test\targetDir\MyProject.xml + ]]) +end + +function suite.documentationFileEmpty() + prepareEmpty() + test.capture [[ + test\targetDir\MyProject.xml + ]] +end + +function suite.documentationFilePath() + prepareDir() + test.capture [[ + test\MyProject.xml + ]] + +end + From 753b78e39b22b0ccf65e51b6ececeac77b1530a6 Mon Sep 17 00:00:00 2001 From: robbe beernaert Date: Thu, 29 Jun 2023 22:10:45 +0200 Subject: [PATCH 03/58] removed null opt to not enable documentationFile --- .../tests/cs2005/test_documentation_file.lua | 14 -------------- modules/vstudio/vs2005_dotnetbase.lua | 2 +- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/modules/vstudio/tests/cs2005/test_documentation_file.lua b/modules/vstudio/tests/cs2005/test_documentation_file.lua index 29de3a2032..fbf7b829e0 100644 --- a/modules/vstudio/tests/cs2005/test_documentation_file.lua +++ b/modules/vstudio/tests/cs2005/test_documentation_file.lua @@ -35,13 +35,6 @@ prj = test.getproject(wks, 1) end - - - local function prepareNil() - prepare() - setConfig() - end - local function prepareEmpty() prepare() documentationFile "" @@ -58,13 +51,6 @@ -- Test Eempty and Nil -- -function suite.documentationFileNil() - prepareNil() - test.capture([[ - test\targetDir\MyProject.xml - ]]) -end - function suite.documentationFileEmpty() prepareEmpty() test.capture [[ diff --git a/modules/vstudio/vs2005_dotnetbase.lua b/modules/vstudio/vs2005_dotnetbase.lua index cc46024b1b..fb783e8836 100644 --- a/modules/vstudio/vs2005_dotnetbase.lua +++ b/modules/vstudio/vs2005_dotnetbase.lua @@ -757,7 +757,7 @@ function dotnetbase.documentationFile(cfg) if cfg.documentationFile and cfg.documentationFile ~= "" then _p(2, string.format('%s\\%s.xml', vstudio.path(cfg, cfg.documentationFile),cfg.project.name)) - else + elseif cfg.documentationFile then _p(2, string.format('%s\\%s.xml',vstudio.path(cfg, cfg.targetdir),cfg.project.name)) end end From c74f42f8b2305bd528134326548f1d028508ef79 Mon Sep 17 00:00:00 2001 From: robbe beernaert Date: Thu, 29 Jun 2023 22:27:51 +0200 Subject: [PATCH 04/58] add documentationFile documentation --- website/docs/documentationFile.md | 41 +++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 website/docs/documentationFile.md diff --git a/website/docs/documentationFile.md b/website/docs/documentationFile.md new file mode 100644 index 0000000000..c6c294f346 --- /dev/null +++ b/website/docs/documentationFile.md @@ -0,0 +1,41 @@ +--- +title: documentationFile +--- + +Enable C# xmlDocumentationFile + +# Usage (2) # +the xmlDocumentationFile is used for adding the [xml comments](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/xmldoc/) added to functions to a dll that has been packed inside a framework or other C# related dll that is refernced inside another project. + +this feature sets the [documentationFIle](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/output#documentationfile) option inside csproj for each corresponding [configuration](https://premake.github.io/docs/configurations/) + +## 1) Default ## + +when you put documentationFile inside the project the following filename/path will be generated: +```%{targetdir}/%{prj.name}.xml``` +```lua +documentationFile "" +``` + +## 2) Custom Directory ## + +when you put the following inside the project the following filename/path will be generated: +```bin\test\%{prj.name}.xml``` + +```lua +documentationFile "bin/test" +``` + +### Applies To ### + +The `project` scope. + +### Availability ### + +Visual Studio 2005 + +## NOTE ! ## +it is recommended to use the default option because visualStudio can only apply the xmlDocumentationFile when it is placed dirrectly next to the corresponding dll. + +## See Also ## +more [info](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/xmldoc/#create-xml-documentation-output) From 3c168d940c1419aab4cfbaf02356e47dbf502e49 Mon Sep 17 00:00:00 2001 From: robbe beernaert Date: Thu, 29 Jun 2023 22:27:51 +0200 Subject: [PATCH 05/58] add documentationFile documentation --- website/docs/documentationFile.md | 41 +++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 website/docs/documentationFile.md diff --git a/website/docs/documentationFile.md b/website/docs/documentationFile.md new file mode 100644 index 0000000000..da61fd4d76 --- /dev/null +++ b/website/docs/documentationFile.md @@ -0,0 +1,41 @@ +--- +title: documentationFile +--- + +Enable C# xmlDocumentationFile + +# Usage (2) # +the xmlDocumentationFile is used for adding the [xml comments](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/xmldoc/) added to functions to a dll that has been packed inside a framework or other C# related dll that is refernced inside another project. + +this feature sets the [documentationFIle](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/output#documentationfile) option inside csproj for each corresponding [configuration](https://premake.github.io/docs/configurations/) + +## 1) Default ## + +when you put documentationFile inside the project, the following filename/path will be generated: +```%{targetdir}/%{prj.name}.xml``` +```lua +documentationFile "" +``` + +## 2) Custom Directory ## + +when you put the following inside the project, the following filename/path will be generated: +```bin\test\%{prj.name}.xml``` + +```lua +documentationFile "bin/test" +``` + +### Applies To ### + +The `project` scope. + +### Availability ### + +Visual Studio 2005 + +## NOTE ! ## +it is recommended to use the default option because visualStudio can only apply the xmlDocumentationFile when it is placed dirrectly next to the corresponding dll. + +## See Also ## +more [info](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/xmldoc/#create-xml-documentation-output) From 3c60b2c32788c33088fd439671db51a55fd547f2 Mon Sep 17 00:00:00 2001 From: robbe beernaert Date: Sat, 1 Jul 2023 10:31:58 +0200 Subject: [PATCH 06/58] added some extra info for custom dir --- website/docs/documentationFile.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/docs/documentationFile.md b/website/docs/documentationFile.md index e8e3cbe430..fa586ff9bd 100644 --- a/website/docs/documentationFile.md +++ b/website/docs/documentationFile.md @@ -25,6 +25,7 @@ when you put the following inside the project the following filename/path will b ```lua documentationFile "bin/test" ``` +the path is rellative to the projects [location](https://premake.github.io/docs/location/) ### Applies To ### From aa6bac070916444b1c8ee26c24c8dcb28d9dacbd Mon Sep 17 00:00:00 2001 From: robbe beernaert Date: Tue, 4 Jul 2023 21:20:05 +0200 Subject: [PATCH 07/58] implemented comments --- .../tests/cs2005/test_documentation_file.lua | 33 +++++++++---------- modules/vstudio/vs2005_dotnetbase.lua | 2 +- src/_premake_init.lua | 2 +- website/docs/documentationFile.md | 13 ++++---- 4 files changed, 24 insertions(+), 26 deletions(-) diff --git a/modules/vstudio/tests/cs2005/test_documentation_file.lua b/modules/vstudio/tests/cs2005/test_documentation_file.lua index fbf7b829e0..c6cecfd78b 100644 --- a/modules/vstudio/tests/cs2005/test_documentation_file.lua +++ b/modules/vstudio/tests/cs2005/test_documentation_file.lua @@ -1,7 +1,7 @@ -- -- tests/actions/vstudio/cs2005/test_debug_props.lua --- Test debugging and optimization flags block of a Visual Studio 2005+ C# project. --- Copyright (c) 2012-2013 Jason Perkins and the Premake project +-- Test DocumentationFile feature Visual Studio 2005+ C# project. +-- Copyright (c) 2012-2023 Jason Perkins and the Premake project -- local p = premake local suite = test.declare("vstudio_cs2005_documentation_file") @@ -18,15 +18,14 @@ function suite.setup() p.action.set("vs2010") wks = test.createWorkspace() - configurations { "Debug", "Release" } - -- project "documentationFile" + configurations { "Debug", "Release" } language "C#" targetdir("test\\targetDir") end local function setConfig() local cfg = test.getconfig(prj, "Debug") - dn2005.documentationFile(cfg); + dn2005.documentationfile(cfg); end @@ -37,32 +36,30 @@ local function prepareEmpty() prepare() - documentationFile "" + documentationfile "" setConfig() end local function prepareDir() prepare() - documentationFile "test" + documentationfile "test" setConfig() end --- --- Test Eempty and Nil --- - -function suite.documentationFileEmpty() - prepareEmpty() - test.capture [[ - test\targetDir\MyProject.xml - ]] -end + local function prepareNull() + p.action.set("vs2010") + wks = test.createWorkspace() + setConfig() + end function suite.documentationFilePath() prepareDir() test.capture [[ test\MyProject.xml ]] - end +function suite.documentationNull() + prepareNull() + test.isemptycapture() +end diff --git a/modules/vstudio/vs2005_dotnetbase.lua b/modules/vstudio/vs2005_dotnetbase.lua index fb783e8836..d89d3f8f4f 100644 --- a/modules/vstudio/vs2005_dotnetbase.lua +++ b/modules/vstudio/vs2005_dotnetbase.lua @@ -754,7 +754,7 @@ end end - function dotnetbase.documentationFile(cfg) + function dotnetbase.documentationfile(cfg) if cfg.documentationFile and cfg.documentationFile ~= "" then _p(2, string.format('%s\\%s.xml', vstudio.path(cfg, cfg.documentationFile),cfg.project.name)) elseif cfg.documentationFile then diff --git a/src/_premake_init.lua b/src/_premake_init.lua index 2a24d94e6d..00d9d42240 100644 --- a/src/_premake_init.lua +++ b/src/_premake_init.lua @@ -766,7 +766,7 @@ } api.register { - name = "documentationFile", + name = "documentationfile", scope = "project", kind = "string", } diff --git a/website/docs/documentationFile.md b/website/docs/documentationFile.md index fa586ff9bd..ebac962e6d 100644 --- a/website/docs/documentationFile.md +++ b/website/docs/documentationFile.md @@ -5,16 +5,17 @@ title: documentationFile Enable C# xmlDocumentationFile # Usage (2) # -the xmlDocumentationFile is used for adding the [xml comments](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/xmldoc/) added to functions to a dll that has been packed inside a framework or other C# related dll that is refernced inside another project. +the DocumentationFile is used for adding the [xml comments](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/xmldoc/) added to functions/ variables, to a dll that has been packed inside a framework or other C# related. +this can then be referenced inside another project by placing it next to the corresponding dll. -this feature sets the [documentationFIle](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/output#documentationfile) option inside csproj for each corresponding [configuration](https://premake.github.io/docs/configurations/) +this feature sets the [DocumentationFile](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/output#documentationfile) option inside csproj for each corresponding [configuration](https://premake.github.io/docs/configurations/) ## 1) Default ## -when you put documentationFile inside the project, the following filename/path will be generated: +when you put documentationfile inside the project, the following filename/path will be generated: ```%{targetdir}/%{prj.name}.xml``` ```lua -documentationFile "" +documentationfile "" ``` ## 2) Custom Directory ## @@ -23,7 +24,7 @@ when you put the following inside the project the following filename/path will b ```bin\test\%{prj.name}.xml``` ```lua -documentationFile "bin/test" +documentationfile "bin/test" ``` the path is rellative to the projects [location](https://premake.github.io/docs/location/) @@ -36,7 +37,7 @@ The `project` scope. Visual Studio 2005 ## NOTE ! ## -it is recommended to use the default option because visualStudio can only apply the xmlDocumentationFile when it is placed dirrectly next to the corresponding dll. +it is recommended to use the default option because Visual Studio can only apply the DocumentationFile when it is placed dirrectly next to the corresponding dll. ## See Also ## more [info](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/xmldoc/#create-xml-documentation-output) From faae641a7cbf578d1404b036e7ba261873171f43 Mon Sep 17 00:00:00 2001 From: robbe beernaert Date: Tue, 4 Jul 2023 21:21:55 +0200 Subject: [PATCH 08/58] fixed title --- website/docs/documentationFile.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/documentationFile.md b/website/docs/documentationFile.md index ebac962e6d..40540ec7df 100644 --- a/website/docs/documentationFile.md +++ b/website/docs/documentationFile.md @@ -1,5 +1,5 @@ --- -title: documentationFile +title: documentationfile --- Enable C# xmlDocumentationFile From 17a9b04cf421779c08fb58f9688ba3b6666f07c2 Mon Sep 17 00:00:00 2001 From: robbe beernaert Date: Thu, 6 Jul 2023 15:43:10 +0200 Subject: [PATCH 09/58] fixed spelling + addd test --- modules/vstudio/tests/cs2005/test_documentation_file.lua | 7 +++++++ modules/vstudio/vs2005_dotnetbase.lua | 7 +++---- website/docs/documentationFile.md | 4 ++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/modules/vstudio/tests/cs2005/test_documentation_file.lua b/modules/vstudio/tests/cs2005/test_documentation_file.lua index c6cecfd78b..da6cf88fbc 100644 --- a/modules/vstudio/tests/cs2005/test_documentation_file.lua +++ b/modules/vstudio/tests/cs2005/test_documentation_file.lua @@ -59,6 +59,13 @@ function suite.documentationFilePath() ]] end +function suite.documentationEmpty() + prepareEmpty() + test.capture [[ + test\targetDir\MyProject.xml + ]] +end + function suite.documentationNull() prepareNull() test.isemptycapture() diff --git a/modules/vstudio/vs2005_dotnetbase.lua b/modules/vstudio/vs2005_dotnetbase.lua index d89d3f8f4f..f418dd0293 100644 --- a/modules/vstudio/vs2005_dotnetbase.lua +++ b/modules/vstudio/vs2005_dotnetbase.lua @@ -755,10 +755,9 @@ end function dotnetbase.documentationfile(cfg) - if cfg.documentationFile and cfg.documentationFile ~= "" then - _p(2, string.format('%s\\%s.xml', vstudio.path(cfg, cfg.documentationFile),cfg.project.name)) - elseif cfg.documentationFile then - _p(2, string.format('%s\\%s.xml',vstudio.path(cfg, cfg.targetdir),cfg.project.name)) + if cfg.documentationFile then + local documentationFile = iif(cfg.documentationFile ~= "", cfg.documentationFile, cfg.targetdir) + _p(2, string.format('%s\\%s.xml', vstudio.path(cfg, documentationFile),cfg.project.name)) end end diff --git a/website/docs/documentationFile.md b/website/docs/documentationFile.md index 40540ec7df..5e930029a5 100644 --- a/website/docs/documentationFile.md +++ b/website/docs/documentationFile.md @@ -26,7 +26,7 @@ when you put the following inside the project the following filename/path will b ```lua documentationfile "bin/test" ``` -the path is rellative to the projects [location](https://premake.github.io/docs/location/) +the path is relative to the project [location](https://premake.github.io/docs/location/) ### Applies To ### @@ -37,7 +37,7 @@ The `project` scope. Visual Studio 2005 ## NOTE ! ## -it is recommended to use the default option because Visual Studio can only apply the DocumentationFile when it is placed dirrectly next to the corresponding dll. +it is recommended to use the default option because Visual Studio can only apply the DocumentationFile when it is placed directly next to the corresponding dll. ## See Also ## more [info](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/xmldoc/#create-xml-documentation-output) From ac1b8cb7f15884467549facf5675d5dfd7bbe506 Mon Sep 17 00:00:00 2001 From: robbe beernaert Date: Thu, 6 Jul 2023 15:43:10 +0200 Subject: [PATCH 10/58] fixed spelling + addd test --- modules/vstudio/tests/cs2005/test_documentation_file.lua | 9 ++++++++- modules/vstudio/vs2005_dotnetbase.lua | 7 +++---- website/docs/documentationFile.md | 4 ++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/modules/vstudio/tests/cs2005/test_documentation_file.lua b/modules/vstudio/tests/cs2005/test_documentation_file.lua index c6cecfd78b..a811afc3f1 100644 --- a/modules/vstudio/tests/cs2005/test_documentation_file.lua +++ b/modules/vstudio/tests/cs2005/test_documentation_file.lua @@ -1,5 +1,5 @@ -- --- tests/actions/vstudio/cs2005/test_debug_props.lua +-- tests/actions/vstudio/cs2005/test_documentation_file.lua -- Test DocumentationFile feature Visual Studio 2005+ C# project. -- Copyright (c) 2012-2023 Jason Perkins and the Premake project -- @@ -59,6 +59,13 @@ function suite.documentationFilePath() ]] end +function suite.documentationEmpty() + prepareEmpty() + test.capture [[ + test\targetDir\MyProject.xml + ]] +end + function suite.documentationNull() prepareNull() test.isemptycapture() diff --git a/modules/vstudio/vs2005_dotnetbase.lua b/modules/vstudio/vs2005_dotnetbase.lua index d89d3f8f4f..f418dd0293 100644 --- a/modules/vstudio/vs2005_dotnetbase.lua +++ b/modules/vstudio/vs2005_dotnetbase.lua @@ -755,10 +755,9 @@ end function dotnetbase.documentationfile(cfg) - if cfg.documentationFile and cfg.documentationFile ~= "" then - _p(2, string.format('%s\\%s.xml', vstudio.path(cfg, cfg.documentationFile),cfg.project.name)) - elseif cfg.documentationFile then - _p(2, string.format('%s\\%s.xml',vstudio.path(cfg, cfg.targetdir),cfg.project.name)) + if cfg.documentationFile then + local documentationFile = iif(cfg.documentationFile ~= "", cfg.documentationFile, cfg.targetdir) + _p(2, string.format('%s\\%s.xml', vstudio.path(cfg, documentationFile),cfg.project.name)) end end diff --git a/website/docs/documentationFile.md b/website/docs/documentationFile.md index 40540ec7df..5e930029a5 100644 --- a/website/docs/documentationFile.md +++ b/website/docs/documentationFile.md @@ -26,7 +26,7 @@ when you put the following inside the project the following filename/path will b ```lua documentationfile "bin/test" ``` -the path is rellative to the projects [location](https://premake.github.io/docs/location/) +the path is relative to the project [location](https://premake.github.io/docs/location/) ### Applies To ### @@ -37,7 +37,7 @@ The `project` scope. Visual Studio 2005 ## NOTE ! ## -it is recommended to use the default option because Visual Studio can only apply the DocumentationFile when it is placed dirrectly next to the corresponding dll. +it is recommended to use the default option because Visual Studio can only apply the DocumentationFile when it is placed directly next to the corresponding dll. ## See Also ## more [info](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/xmldoc/#create-xml-documentation-output) From a228108e2003d5d5988bbba073184d41a101c854 Mon Sep 17 00:00:00 2001 From: robbe beernaert Date: Wed, 30 Aug 2023 20:28:39 +0200 Subject: [PATCH 11/58] improved grammar / capitalization --- website/docs/documentationFile.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/website/docs/documentationFile.md b/website/docs/documentationFile.md index 5e930029a5..27dfbb97d3 100644 --- a/website/docs/documentationFile.md +++ b/website/docs/documentationFile.md @@ -1,18 +1,18 @@ --- -title: documentationfile +title: documentation file --- -Enable C# xmlDocumentationFile +Enables C# xmlDocumentationFile # Usage (2) # -the DocumentationFile is used for adding the [xml comments](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/xmldoc/) added to functions/ variables, to a dll that has been packed inside a framework or other C# related. -this can then be referenced inside another project by placing it next to the corresponding dll. +The Documentation File is used for adding the [xml comments](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/xmldoc/) added to functions/ variables, to a dll that has been packed inside a framework or other C# related project. +This can then be referenced inside another project by placing it next to the corresponding dll. -this feature sets the [DocumentationFile](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/output#documentationfile) option inside csproj for each corresponding [configuration](https://premake.github.io/docs/configurations/) +This feature sets the [Documentation File](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/output#documentationfile) option inside csproj for each corresponding [configuration](https://premake.github.io/docs/configurations/) ## 1) Default ## -when you put documentationfile inside the project, the following filename/path will be generated: +When you put **documentationfile** inside the project configuration, the following filename/path will be generated: ```%{targetdir}/%{prj.name}.xml``` ```lua documentationfile "" @@ -20,13 +20,13 @@ documentationfile "" ## 2) Custom Directory ## -when you put the following inside the project the following filename/path will be generated: +When you put the following inside the project configuration the following filename/path will be generated: ```bin\test\%{prj.name}.xml``` ```lua documentationfile "bin/test" ``` -the path is relative to the project [location](https://premake.github.io/docs/location/) +The path is relative to the project [location](https://premake.github.io/docs/location/) ### Applies To ### @@ -37,7 +37,7 @@ The `project` scope. Visual Studio 2005 ## NOTE ! ## -it is recommended to use the default option because Visual Studio can only apply the DocumentationFile when it is placed directly next to the corresponding dll. +It is recommended to use the default option because Visual Studio can only apply the Documentation File when it is placed directly next to the corresponding DLL. ## See Also ## -more [info](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/xmldoc/#create-xml-documentation-output) +More [info](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/xmldoc/#create-xml-documentation-output) From fe84d57101716034c077f7ec35ff4693590aef39 Mon Sep 17 00:00:00 2001 From: robbe beernaert Date: Thu, 31 Aug 2023 14:48:00 +0200 Subject: [PATCH 12/58] changed styling of the documentation --- website/docs/documentationFile.md | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/website/docs/documentationFile.md b/website/docs/documentationFile.md index 27dfbb97d3..f93fa52c31 100644 --- a/website/docs/documentationFile.md +++ b/website/docs/documentationFile.md @@ -1,16 +1,17 @@ ---- -title: documentation file ---- - Enables C# xmlDocumentationFile -# Usage (2) # The Documentation File is used for adding the [xml comments](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/xmldoc/) added to functions/ variables, to a dll that has been packed inside a framework or other C# related project. This can then be referenced inside another project by placing it next to the corresponding dll. This feature sets the [Documentation File](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/output#documentationfile) option inside csproj for each corresponding [configuration](https://premake.github.io/docs/configurations/) -## 1) Default ## +```lua +documentationfile "targetdir" +``` +### Parameters ### +`targetdir` is the directory where the Documentation File should be placed after building the project using Visual Studio. + +### Examples ### When you put **documentationfile** inside the project configuration, the following filename/path will be generated: ```%{targetdir}/%{prj.name}.xml``` @@ -18,26 +19,24 @@ When you put **documentationfile** inside the project configuration, the followi documentationfile "" ``` -## 2) Custom Directory ## - When you put the following inside the project configuration the following filename/path will be generated: ```bin\test\%{prj.name}.xml``` ```lua documentationfile "bin/test" ``` -The path is relative to the project [location](https://premake.github.io/docs/location/) - ### Applies To ### -The `project` scope. +Project configurations. ### Availability ### -Visual Studio 2005 +Premake 5.0 or later. + +Visual Studio 2005 C# is the only toolset currently supported. -## NOTE ! ## +### Warning ### It is recommended to use the default option because Visual Studio can only apply the Documentation File when it is placed directly next to the corresponding DLL. -## See Also ## +### See Also ### More [info](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/xmldoc/#create-xml-documentation-output) From e831595328280640326c12a5f0cd9881e8bacc7c Mon Sep 17 00:00:00 2001 From: robbe beernaert Date: Sat, 2 Sep 2023 21:09:58 +0200 Subject: [PATCH 13/58] changed docs to fit api --- website/docs/documentationFile.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/documentationFile.md b/website/docs/documentationFile.md index f93fa52c31..52fbf25dc5 100644 --- a/website/docs/documentationFile.md +++ b/website/docs/documentationFile.md @@ -23,7 +23,7 @@ When you put the following inside the project configuration the following filena ```bin\test\%{prj.name}.xml``` ```lua -documentationfile "bin/test" +documentationfile "%{prj.location}/bin/test" ``` ### Applies To ### From dbd70b51b9fb252a56335f8e69486315b8fdb8fc Mon Sep 17 00:00:00 2001 From: robbe beernaert Date: Sat, 2 Sep 2023 21:42:01 +0200 Subject: [PATCH 14/58] added MSFT links to See Also --- website/docs/documentationFile.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/website/docs/documentationFile.md b/website/docs/documentationFile.md index 52fbf25dc5..3537a2a16f 100644 --- a/website/docs/documentationFile.md +++ b/website/docs/documentationFile.md @@ -40,3 +40,6 @@ It is recommended to use the default option because Visual Studio can only apply ### See Also ### More [info](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/xmldoc/#create-xml-documentation-output) +[xml comments](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/xmldoc/) +[Documentation File](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/output#documentationfile) +[configuration](https://premake.github.io/docs/configurations/) From 19715ddcda23edf81a92f6d02e10f3d58831483d Mon Sep 17 00:00:00 2001 From: Beernaert Robbe Date: Sun, 1 Oct 2023 18:36:18 +0200 Subject: [PATCH 15/58] fixed capitalization --- website/docs/documentationFile.md | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/website/docs/documentationFile.md b/website/docs/documentationFile.md index 3537a2a16f..2deb939732 100644 --- a/website/docs/documentationFile.md +++ b/website/docs/documentationFile.md @@ -1,15 +1,15 @@ Enables C# xmlDocumentationFile -The Documentation File is used for adding the [xml comments](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/xmldoc/) added to functions/ variables, to a dll that has been packed inside a framework or other C# related project. -This can then be referenced inside another project by placing it next to the corresponding dll. +The documentation file is used for adding [xml comments](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/xmldoc/) to a dll that has been packed inside a framework or other C# related project. +This can then be referenced inside other projects by placing it next to the corresponding dll. -This feature sets the [Documentation File](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/output#documentationfile) option inside csproj for each corresponding [configuration](https://premake.github.io/docs/configurations/) +This feature sets the [documentationfile](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/output#documentationfile) option inside csproj for each corresponding [configuration](https://premake.github.io/docs/configurations/) ```lua documentationfile "targetdir" ``` ### Parameters ### -`targetdir` is the directory where the Documentation File should be placed after building the project using Visual Studio. +`targetdir` is the directory where the documentation file should be placed after building the project using visual studio. ### Examples ### @@ -19,7 +19,7 @@ When you put **documentationfile** inside the project configuration, the followi documentationfile "" ``` -When you put the following inside the project configuration the following filename/path will be generated: +When you put the following inside the project configuration, the following filename/path will be generated: ```bin\test\%{prj.name}.xml``` ```lua @@ -33,13 +33,12 @@ Project configurations. Premake 5.0 or later. -Visual Studio 2005 C# is the only toolset currently supported. +Visual studio 2005 C# is the only toolset currently supported. ### Warning ### -It is recommended to use the default option because Visual Studio can only apply the Documentation File when it is placed directly next to the corresponding DLL. - +default option is recommendes because visual studio cannot detect the xml file if the name is the same as the dll. ### See Also ### More [info](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/xmldoc/#create-xml-documentation-output) [xml comments](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/xmldoc/) -[Documentation File](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/output#documentationfile) +[documentation file](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/output#documentationfile) [configuration](https://premake.github.io/docs/configurations/) From ce31e60d7654ff5aa149b6e1bfe803cadafe416f Mon Sep 17 00:00:00 2001 From: Beernaert Robbe Date: Sun, 1 Oct 2023 18:52:48 +0200 Subject: [PATCH 16/58] changed wording/ capitalization of documentation --- website/docs/documentationFile.md | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/website/docs/documentationFile.md b/website/docs/documentationFile.md index 2deb939732..71eaa698c9 100644 --- a/website/docs/documentationFile.md +++ b/website/docs/documentationFile.md @@ -1,9 +1,11 @@ Enables C# xmlDocumentationFile -The documentation file is used for adding [xml comments](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/xmldoc/) to a dll that has been packed inside a framework or other C# related project. -This can then be referenced inside other projects by placing it next to the corresponding dll. +The `xmlDocumentationFile` option is used to include [XML comments](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/xmldoc/) in a DLL that has been included in a .NET framework or another C# project. These XML comments can then be referenced by other projects when placed alongside the corresponding DLL. -This feature sets the [documentationfile](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/output#documentationfile) option inside csproj for each corresponding [configuration](https://premake.github.io/docs/configurations/) +This feature sets the [documentationfile](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/output#documentationfile) option in a C# project's .csproj file for each respective [configuration](https://premake.github.io/docs/configurations/) + +## Usage ## +To use xmlDocumentationFile, add the following line to your project configuration in your Premake script: ```lua documentationfile "targetdir" @@ -13,18 +15,17 @@ documentationfile "targetdir" ### Examples ### -When you put **documentationfile** inside the project configuration, the following filename/path will be generated: +When you specify an empty string for `documentationfile`, the following filename/path will be generated: ```%{targetdir}/%{prj.name}.xml``` ```lua documentationfile "" ``` - -When you put the following inside the project configuration, the following filename/path will be generated: -```bin\test\%{prj.name}.xml``` - +If you specify a custom target directory like this: ```lua documentationfile "%{prj.location}/bin/test" ``` + the following filename/path will be generated: +```bin\test\%{prj.name}.xml``` ### Applies To ### Project configurations. @@ -36,9 +37,10 @@ Premake 5.0 or later. Visual studio 2005 C# is the only toolset currently supported. ### Warning ### -default option is recommendes because visual studio cannot detect the xml file if the name is the same as the dll. +It's recommended to use the default option because Visual Studio may not detect the XML file if its name is not the same as the DLL. + ### See Also ### -More [info](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/xmldoc/#create-xml-documentation-output) -[xml comments](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/xmldoc/) -[documentation file](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/output#documentationfile) -[configuration](https://premake.github.io/docs/configurations/) +For more information on XML documentation in C#, refer to: +1) [xml comments](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/xmldoc/) +2) [documentation file](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/output#documentationfile) +3) [configuration](https://premake.github.io/docs/configurations/) From 40167feef191a194d7586b53ed775ad5ec0f4292 Mon Sep 17 00:00:00 2001 From: Beernaert Robbe Date: Mon, 2 Oct 2023 13:47:51 +0200 Subject: [PATCH 17/58] removed the slashes! --- website/docs/documentationFile.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/website/docs/documentationFile.md b/website/docs/documentationFile.md index 71eaa698c9..2fdf143263 100644 --- a/website/docs/documentationFile.md +++ b/website/docs/documentationFile.md @@ -5,7 +5,7 @@ The `xmlDocumentationFile` option is used to include [XML comments](https://lear This feature sets the [documentationfile](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/output#documentationfile) option in a C# project's .csproj file for each respective [configuration](https://premake.github.io/docs/configurations/) ## Usage ## -To use xmlDocumentationFile, add the following line to your project configuration in your Premake script: +To use xmlDocumentationFile, add the following line to your project configuration in your premake script: ```lua documentationfile "targetdir" @@ -15,7 +15,7 @@ documentationfile "targetdir" ### Examples ### -When you specify an empty string for `documentationfile`, the following filename/path will be generated: +When you specify an empty string for `documentationfile`, the following filepath will be generated: ```%{targetdir}/%{prj.name}.xml``` ```lua documentationfile "" @@ -24,7 +24,7 @@ If you specify a custom target directory like this: ```lua documentationfile "%{prj.location}/bin/test" ``` - the following filename/path will be generated: + the following filepath will be generated: ```bin\test\%{prj.name}.xml``` ### Applies To ### From 9707d8f52334123f3f6014f6a312e5a43bd69471 Mon Sep 17 00:00:00 2001 From: Beernaert Robbe Date: Thu, 5 Oct 2023 19:45:42 +0200 Subject: [PATCH 18/58] added documenationfile to the sidebar --- website/sidebars.js | 1 + 1 file changed, 1 insertion(+) diff --git a/website/sidebars.js b/website/sidebars.js index ecf0edba68..8cdfed655f 100644 --- a/website/sidebars.js +++ b/website/sidebars.js @@ -131,6 +131,7 @@ module.exports = { 'display', 'docdir', 'docname', + 'documentationfile', 'dofileopt', 'dotnetframework', 'dpiawareness', From 3533b2aaeb5e8b0ec93e45dad11e09aa7eafa440 Mon Sep 17 00:00:00 2001 From: lolrobbe2 <90089980+lolrobbe2@users.noreply.github.com> Date: Tue, 31 Oct 2023 21:13:06 +0100 Subject: [PATCH 19/58] Rename documentationFile.md to documentationfile.md --- website/docs/{documentationFile.md => documentationfile.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename website/docs/{documentationFile.md => documentationfile.md} (100%) diff --git a/website/docs/documentationFile.md b/website/docs/documentationfile.md similarity index 100% rename from website/docs/documentationFile.md rename to website/docs/documentationfile.md From f50609c99154dbd7af0c4d1688dbbfbcbc2134c0 Mon Sep 17 00:00:00 2001 From: Beernaert Robbe Date: Sun, 9 Jun 2024 21:27:18 +0200 Subject: [PATCH 20/58] added support for newer tag (functional result stays the same) --- .../tests/cs2005/test_documentation_file.lua | 16 ++++++++++++++++ modules/vstudio/vs2005_csproj.lua | 2 +- modules/vstudio/vs2005_dotnetbase.lua | 8 ++++++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/modules/vstudio/tests/cs2005/test_documentation_file.lua b/modules/vstudio/tests/cs2005/test_documentation_file.lua index a811afc3f1..aa214c0750 100644 --- a/modules/vstudio/tests/cs2005/test_documentation_file.lua +++ b/modules/vstudio/tests/cs2005/test_documentation_file.lua @@ -59,6 +59,14 @@ function suite.documentationFilePath() ]] end +function suite.documentationFilePath_vs2017up() + p.action.set("vs2017") + prepareDir() + test.capture [[ + test\MyProject.xml + ]] +end + function suite.documentationEmpty() prepareEmpty() test.capture [[ @@ -66,7 +74,15 @@ function suite.documentationEmpty() ]] end +function suite.documentationEmpty_vs2017up() + p.action.set("vs2017") + prepareEmpty() + test.capture [[true]] +end + function suite.documentationNull() prepareNull() test.isemptycapture() end + + diff --git a/modules/vstudio/vs2005_csproj.lua b/modules/vstudio/vs2005_csproj.lua index fe8873ecf1..4c0c1fd833 100644 --- a/modules/vstudio/vs2005_csproj.lua +++ b/modules/vstudio/vs2005_csproj.lua @@ -82,7 +82,7 @@ dotnetbase.outputProps, dotnetbase.compilerProps, dotnetbase.additionalProps, - dotnetbase.NoWarn,, + dotnetbase.NoWarn, dotnetbase.documentationFile, } end diff --git a/modules/vstudio/vs2005_dotnetbase.lua b/modules/vstudio/vs2005_dotnetbase.lua index 460d921709..dcc16260be 100644 --- a/modules/vstudio/vs2005_dotnetbase.lua +++ b/modules/vstudio/vs2005_dotnetbase.lua @@ -769,8 +769,12 @@ function dotnetbase.documentationfile(cfg) if cfg.documentationFile then - local documentationFile = iif(cfg.documentationFile ~= "", cfg.documentationFile, cfg.targetdir) - _p(2, string.format('%s\\%s.xml', vstudio.path(cfg, documentationFile),cfg.project.name)) + if _ACTION > "vs2015" and cfg.documentationFile == "" then + _p(2,'true') + else + local documentationFile = iif(cfg.documentationFile ~= "", cfg.documentationFile, cfg.targetdir) + _p(2, string.format('%s\\%s.xml', vstudio.path(cfg, documentationFile),cfg.project.name)) + end end end From 44165f5dd3fd9093263189c320f790de48d64ac0 Mon Sep 17 00:00:00 2001 From: Beernaert Robbe Date: Fri, 27 Sep 2024 22:41:33 +0200 Subject: [PATCH 21/58] changed tests --- .../tests/cs2005/test_documentation_file.lua | 44 +++++++++---------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/modules/vstudio/tests/cs2005/test_documentation_file.lua b/modules/vstudio/tests/cs2005/test_documentation_file.lua index aa214c0750..5eea012dbf 100644 --- a/modules/vstudio/tests/cs2005/test_documentation_file.lua +++ b/modules/vstudio/tests/cs2005/test_documentation_file.lua @@ -20,7 +20,7 @@ wks = test.createWorkspace() configurations { "Debug", "Release" } language "C#" - targetdir("test\\targetDir") + targetdir("test/targetDir") end local function setConfig() @@ -34,26 +34,10 @@ prj = test.getproject(wks, 1) end - local function prepareEmpty() - prepare() - documentationfile "" - setConfig() - end - - local function prepareDir() - prepare() - documentationfile "test" - setConfig() - end - - local function prepareNull() - p.action.set("vs2010") - wks = test.createWorkspace() - setConfig() - end - function suite.documentationFilePath() - prepareDir() + prepare() + documentationfile "test" + setConfig() test.capture [[ test\MyProject.xml ]] @@ -61,14 +45,21 @@ end function suite.documentationFilePath_vs2017up() p.action.set("vs2017") - prepareDir() + + prepare() + documentationfile "test" + setConfig() + test.capture [[ test\MyProject.xml ]] end function suite.documentationEmpty() - prepareEmpty() + prepare() + documentationfile "" + setConfig() + test.capture [[ test\targetDir\MyProject.xml ]] @@ -76,12 +67,17 @@ end function suite.documentationEmpty_vs2017up() p.action.set("vs2017") - prepareEmpty() + + prepare() + documentationfile "" + setConfig() + test.capture [[true]] end function suite.documentationNull() - prepareNull() + wks = test.createWorkspace() + setConfig() test.isemptycapture() end From ef4ac4d041a705de72d65418916277de82468cda Mon Sep 17 00:00:00 2001 From: Beernaert Robbe Date: Fri, 27 Sep 2024 23:12:00 +0200 Subject: [PATCH 22/58] changed default from documentationfile "" to documentationfile(true) --- .../vstudio/tests/cs2005/test_documentation_file.lua | 11 ++++++----- modules/vstudio/vs2005_dotnetbase.lua | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/modules/vstudio/tests/cs2005/test_documentation_file.lua b/modules/vstudio/tests/cs2005/test_documentation_file.lua index 5eea012dbf..cfa79694cd 100644 --- a/modules/vstudio/tests/cs2005/test_documentation_file.lua +++ b/modules/vstudio/tests/cs2005/test_documentation_file.lua @@ -1,7 +1,7 @@ -- -- tests/actions/vstudio/cs2005/test_documentation_file.lua -- Test DocumentationFile feature Visual Studio 2005+ C# project. --- Copyright (c) 2012-2023 Jason Perkins and the Premake project +-- Copyright (c) 2012-2024 Jason Perkins and the Premake project -- local p = premake local suite = test.declare("vstudio_cs2005_documentation_file") @@ -36,7 +36,7 @@ function suite.documentationFilePath() prepare() - documentationfile "test" + documentationfile("test") setConfig() test.capture [[ test\MyProject.xml @@ -47,7 +47,7 @@ function suite.documentationFilePath_vs2017up() p.action.set("vs2017") prepare() - documentationfile "test" + documentationfile("test") setConfig() test.capture [[ @@ -57,7 +57,7 @@ end function suite.documentationEmpty() prepare() - documentationfile "" + documentationfile(true) setConfig() test.capture [[ @@ -69,7 +69,7 @@ function suite.documentationEmpty_vs2017up() p.action.set("vs2017") prepare() - documentationfile "" + documentationfile(true) setConfig() test.capture [[true]] @@ -77,6 +77,7 @@ end function suite.documentationNull() wks = test.createWorkspace() + prepare() setConfig() test.isemptycapture() end diff --git a/modules/vstudio/vs2005_dotnetbase.lua b/modules/vstudio/vs2005_dotnetbase.lua index 33538177e0..f4df0566a7 100644 --- a/modules/vstudio/vs2005_dotnetbase.lua +++ b/modules/vstudio/vs2005_dotnetbase.lua @@ -780,10 +780,10 @@ function dotnetbase.documentationfile(cfg) if cfg.documentationFile then - if _ACTION > "vs2015" and cfg.documentationFile == "" then + if _ACTION > "vs2015" and cfg.documentationFile == true then _p(2,'true') else - local documentationFile = iif(cfg.documentationFile ~= "", cfg.documentationFile, cfg.targetdir) + local documentationFile = iif(cfg.documentationFile ~= true, cfg.documentationFile, cfg.targetdir) _p(2, string.format('%s\\%s.xml', vstudio.path(cfg, documentationFile),cfg.project.name)) end end From 3ec3b339aaa962c5e2805d2c1a0b0811fb945656 Mon Sep 17 00:00:00 2001 From: Beernaert Robbe Date: Fri, 27 Sep 2024 23:13:04 +0200 Subject: [PATCH 23/58] changed documentation to match! --- website/docs/documentationfile.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/website/docs/documentationfile.md b/website/docs/documentationfile.md index 2fdf143263..72acebbf25 100644 --- a/website/docs/documentationfile.md +++ b/website/docs/documentationfile.md @@ -1,6 +1,6 @@ Enables C# xmlDocumentationFile -The `xmlDocumentationFile` option is used to include [XML comments](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/xmldoc/) in a DLL that has been included in a .NET framework or another C# project. These XML comments can then be referenced by other projects when placed alongside the corresponding DLL. +The `xmlDocumentationFile` option is used to include [XML comments](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/xmldoc/) in a DLL that has been included in a .NET framework or another C# project. These XML comments can then be referenced by other projects when placed alongside the corresponding SharedLib. This feature sets the [documentationfile](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/output#documentationfile) option in a C# project's .csproj file for each respective [configuration](https://premake.github.io/docs/configurations/) @@ -8,23 +8,23 @@ This feature sets the [documentationfile](https://learn.microsoft.com/en-us/dotn To use xmlDocumentationFile, add the following line to your project configuration in your premake script: ```lua -documentationfile "targetdir" +documentationfile("targetdir") ``` ### Parameters ### `targetdir` is the directory where the documentation file should be placed after building the project using visual studio. ### Examples ### -When you specify an empty string for `documentationfile`, the following filepath will be generated: +When you set documentationFile to true, the following filepath will be generated: ```%{targetdir}/%{prj.name}.xml``` ```lua -documentationfile "" +documentationfile(true) ``` If you specify a custom target directory like this: ```lua -documentationfile "%{prj.location}/bin/test" +documentationfile("%{prj.location}/bin/test") ``` - the following filepath will be generated: +the following filepath will be generated: ```bin\test\%{prj.name}.xml``` ### Applies To ### @@ -37,7 +37,7 @@ Premake 5.0 or later. Visual studio 2005 C# is the only toolset currently supported. ### Warning ### -It's recommended to use the default option because Visual Studio may not detect the XML file if its name is not the same as the DLL. +It's recommended to use `documentationfile(true)` because Visual Studio's intellisense will not detect the XML file if its name is not the same as the SharedLib. ### See Also ### For more information on XML documentation in C#, refer to: From 28374f7fddb4504ff3700c8b52e82a3fad9dda35 Mon Sep 17 00:00:00 2001 From: Beernaert Robbe Date: Fri, 27 Sep 2024 23:20:27 +0200 Subject: [PATCH 24/58] changed availability in docs for documentationfile.md --- website/docs/documentationfile.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/docs/documentationfile.md b/website/docs/documentationfile.md index 72acebbf25..6c86fbdaf8 100644 --- a/website/docs/documentationfile.md +++ b/website/docs/documentationfile.md @@ -32,9 +32,9 @@ Project configurations. ### Availability ### -Premake 5.0 or later. +Premake 5.0 beta3 or later. -Visual studio 2005 C# is the only toolset currently supported. +Visual studio is the only toolset currently supported. ### Warning ### It's recommended to use `documentationfile(true)` because Visual Studio's intellisense will not detect the XML file if its name is not the same as the SharedLib. From d0bd40f6ee8670a3b8cb1d617c673beb95f60c32 Mon Sep 17 00:00:00 2001 From: Beernaert Robbe Date: Mon, 7 Oct 2024 19:00:42 +0200 Subject: [PATCH 25/58] added support to select .NET sdk in visual studio. --- modules/vstudio/tests/_tests.lua | 1 + .../vstudio/tests/cs2005/test_dotnetsdk.lua | 101 ++++++++++++++++++ modules/vstudio/vs2005_csproj.lua | 1 + modules/vstudio/vs2005_dotnetbase.lua | 26 ++++- src/_premake_init.lua | 14 +++ website/docs/dotnetsdk.md | 47 ++++++++ 6 files changed, 189 insertions(+), 1 deletion(-) create mode 100644 modules/vstudio/tests/cs2005/test_dotnetsdk.lua create mode 100644 website/docs/dotnetsdk.md diff --git a/modules/vstudio/tests/_tests.lua b/modules/vstudio/tests/_tests.lua index 82e00e14d9..99e1780e09 100644 --- a/modules/vstudio/tests/_tests.lua +++ b/modules/vstudio/tests/_tests.lua @@ -15,6 +15,7 @@ return { "cs2005/test_debug_props.lua", "cs2005/test_debug_props_2019.lua", "cs2005/test_documentation_file.lua", + "cs2005/test_dotnetsdk.lua" "cs2005/test_files.lua", "cs2005/test_icon.lua", "cs2005/test_netcore.lua", diff --git a/modules/vstudio/tests/cs2005/test_dotnetsdk.lua b/modules/vstudio/tests/cs2005/test_dotnetsdk.lua new file mode 100644 index 0000000000..75a9fb463a --- /dev/null +++ b/modules/vstudio/tests/cs2005/test_dotnetsdk.lua @@ -0,0 +1,101 @@ +-- +-- tests/actions/vstudio/cs2005/test_dotnetsdk.lua +-- Test DocumentationFile feature Visual Studio 2005+ C# project. +-- Copyright (c) 2012-2024 Jason Perkins and the Premake project +-- + local p = premake + local suite = test.declare("vstudio_cs2005_dotnetsdk") + local dn2005 = p.vstudio.dotnetbase +-- +-- Setup +-- + + local wks, prj + +-- +-- Setup and teardown +-- + function suite.setup() + p.action.set("vs2010") + wks = test.createWorkspace() + configurations { "Debug", "Release" } + language "C#" + dotnetframework "net8.0" + end + + local function setConfig() + local cfg = test.getconfig(prj, "Debug") + dn2005.projectElement(cfg); + end + + local function prepare() + prj = test.getproject(wks, 1) + end + +function suite.testDefault() + prepare() + setConfig() + + test.capture [[ + +]] +end + +function suite.testWeb() + prepare() + dotnetsdk "web" + setConfig() + + test.capture [[ + + ]] +end + +function suite.testRazor() + prepare() + dotnetsdk "razor" + setConfig() + + test.capture [[ + + ]] +end + +function suite.testWorker() + prepare() + dotnetsdk "worker" + setConfig() + + test.capture [[ + + ]] +end + +function suite.testBlazor() + prepare() + dotnetsdk "blazor" + setConfig() + + test.capture [[ + + ]] +end + +function suite.testWindowsDesktop() + prepare() + dotnetsdk "windowsdesktop" + setConfig() + + test.capture [[ + + ]] +end +function suite.testMSTest() + prepare() + dotnetsdk "mstest" + setConfig() + + test.capture [[ + + ]] +end diff --git a/modules/vstudio/vs2005_csproj.lua b/modules/vstudio/vs2005_csproj.lua index 4c0c1fd833..cfb9b59cc1 100644 --- a/modules/vstudio/vs2005_csproj.lua +++ b/modules/vstudio/vs2005_csproj.lua @@ -53,6 +53,7 @@ dotnetbase.netcore.useWpf, dotnetbase.csversion, dotnetbase.netcore.enableDefaultCompileItems, + dotnetbase.netcore.dotnetsdk } else return { diff --git a/modules/vstudio/vs2005_dotnetbase.lua b/modules/vstudio/vs2005_dotnetbase.lua index f4df0566a7..c9cd4a5032 100644 --- a/modules/vstudio/vs2005_dotnetbase.lua +++ b/modules/vstudio/vs2005_dotnetbase.lua @@ -60,7 +60,7 @@ if prj.flags.WPF then _p('') else - _p('') + _p('',dotnetbase.netcore.getsdk(prj)) end else local ver = '' @@ -820,6 +820,30 @@ end end + function dotnetbase.netcore.getsdk(cfg) + if cfg.dotnetsdk == "web" then + return "Microsoft.NET.Sdk.Web" + elseif cfg.dotnetsdk == "razor" then + return "Microsoft.NET.Sdk.Razor" + elseif cfg.dotnetsdk == "worker" then + return "Microsoft.NET.Sdk.Worker" + elseif cfg.dotnetsdk == "blazor" then + return "Microsoft.NET.Sdk.BlazorWebAssembly" + elseif cfg.dotnetsdk == "windowsdesktop" then + return "Microsoft.NET.Sdk.WindowsDesktop" + elseif cfg.dotnetsdk == "mstest" then + return "MSTest.Sdk" + elseif not cfg.dotnetsdk then + return "Microsoft.NET.Sdk" + end + end + + function dotnetbase.netcore.dotnetsdk(cfg) + if cfg.dotnetsdk == "mstest" then + _p(2,'') + end + end + function dotnetbase.allowUnsafeBlocks(cfg) if cfg.clr == "Unsafe" then _p(2,'true') diff --git a/src/_premake_init.lua b/src/_premake_init.lua index 6559639d69..5c265e4f41 100644 --- a/src/_premake_init.lua +++ b/src/_premake_init.lua @@ -772,6 +772,20 @@ kind = "string", } + api.register { + name = "dotnetsdk", + scope = "project", + kind = "string", + allowed = { + "web", + "razor", + "worker", + "blazor", + "windowsdesktop", + "mstest" + } + } + api.register { name = "cdialect", scope = "config", diff --git a/website/docs/dotnetsdk.md b/website/docs/dotnetsdk.md new file mode 100644 index 0000000000..5f17a4dd70 --- /dev/null +++ b/website/docs/dotnetsdk.md @@ -0,0 +1,47 @@ +Selects a .NET Sdk + +```lua +dotnetsdk "sdk" +``` + +[overview](https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview) + +## parameters ## +`sdk` is one of + * [web](https://learn.microsoft.com/en-us/aspnet/core/razor-pages/web-sdk?toc=%2Fdotnet%2Fnavigate%2Ftools-diagnostics%2Ftoc.json&bc=%2Fdotnet%2Fbreadcrumb%2Ftoc.json) + * [razor](https://learn.microsoft.com/en-us/aspnet/core/razor-pages/sdk?toc=%2Fdotnet%2Fnavigate%2Ftools-diagnostics%2Ftoc.json&bc=%2Fdotnet%2Fbreadcrumb%2Ftoc.json) + * [worker](https://learn.microsoft.com/en-us/dotnet/core/extensions/workers) + * [blazor](https://learn.microsoft.com/en-us/aspnet/core/blazor/) + * [windowsdesktop](https://learn.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props-desktop?view=aspnetcore-8.0) + * [mstest](https://learn.microsoft.com/en-us/dotnet/core/testing/unit-testing-mstest-sdk) + + +## mstest ## +to make the MSTest sdk work you need to add the version to `global.json`: +```json +{ + "msbuild-sdks": { + "MSTest.Sdk": "3.6.1" + } +} +``` +:::warning +`global.json` needs to be located in the same folder as your solution +::: + +### Applies To ### + +Project configurations. + +### Availability ### + +Premake 5.0 beta3 or later. + +Visual studio is the only toolset currently supported. + +### Examples ### +use the web sdk + +```lua +dotnetsdk "web" +``` From 29fe49ff1fcd7afbc476ba157edbc460152ae318 Mon Sep 17 00:00:00 2001 From: Beernaert Robbe Date: Mon, 7 Oct 2024 19:37:02 +0200 Subject: [PATCH 26/58] updated sidebar.js --- website/sidebars.js | 1 + 1 file changed, 1 insertion(+) diff --git a/website/sidebars.js b/website/sidebars.js index b3b1af0f69..df94560918 100644 --- a/website/sidebars.js +++ b/website/sidebars.js @@ -135,6 +135,7 @@ module.exports = { 'docname', 'documentationfile', 'dotnetframework', + 'dotnetsdk', 'dpiawareness', 'editandcontinue', 'editorintegration', From 8cf3ccc00d06f9fb490c7e08b5f0197dbeb40029 Mon Sep 17 00:00:00 2001 From: Beernaert Robbe Date: Mon, 7 Oct 2024 19:37:16 +0200 Subject: [PATCH 27/58] added comma! --- modules/vstudio/tests/_tests.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/vstudio/tests/_tests.lua b/modules/vstudio/tests/_tests.lua index 99e1780e09..f649b751f3 100644 --- a/modules/vstudio/tests/_tests.lua +++ b/modules/vstudio/tests/_tests.lua @@ -15,7 +15,7 @@ return { "cs2005/test_debug_props.lua", "cs2005/test_debug_props_2019.lua", "cs2005/test_documentation_file.lua", - "cs2005/test_dotnetsdk.lua" + "cs2005/test_dotnetsdk.lua", "cs2005/test_files.lua", "cs2005/test_icon.lua", "cs2005/test_netcore.lua", From 63964d89adc9064af094e474eac5b44d182fdea6 Mon Sep 17 00:00:00 2001 From: lolrobbe2 <90089980+lolrobbe2@users.noreply.github.com> Date: Tue, 8 Oct 2024 19:12:11 +0200 Subject: [PATCH 28/58] use map instead of ugly if else statement. Co-authored-by: Joris Dauphin --- modules/vstudio/vs2005_dotnetbase.lua | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/modules/vstudio/vs2005_dotnetbase.lua b/modules/vstudio/vs2005_dotnetbase.lua index c9cd4a5032..6da8f71ae3 100644 --- a/modules/vstudio/vs2005_dotnetbase.lua +++ b/modules/vstudio/vs2005_dotnetbase.lua @@ -821,20 +821,18 @@ end function dotnetbase.netcore.getsdk(cfg) - if cfg.dotnetsdk == "web" then - return "Microsoft.NET.Sdk.Web" - elseif cfg.dotnetsdk == "razor" then - return "Microsoft.NET.Sdk.Razor" - elseif cfg.dotnetsdk == "worker" then - return "Microsoft.NET.Sdk.Worker" - elseif cfg.dotnetsdk == "blazor" then - return "Microsoft.NET.Sdk.BlazorWebAssembly" - elseif cfg.dotnetsdk == "windowsdesktop" then - return "Microsoft.NET.Sdk.WindowsDesktop" - elseif cfg.dotnetsdk == "mstest" then - return "MSTest.Sdk" - elseif not cfg.dotnetsdk then - return "Microsoft.NET.Sdk" + if not cfg.dotnetsdk then + return "Microsoft.NET.Sdk" + end + local map = { + ["web"] = "Microsoft.NET.Sdk.Web", + ["razor"] = "Microsoft.NET.Sdk.Razor", + ["worker"] = "Microsoft.NET.Sdk.Worker", + ["blazor"] = "Microsoft.NET.Sdk.BlazorWebAssembly", + ["windowsdesktop"] = "Microsoft.NET.Sdk.WindowsDesktop", + ["mstest"] = "MSTest.Sdk", + } + return map[cfg.dotnetsdk] end end From 76b97092c3a07106c7f9d9fd8e3c08d1bb9e8981 Mon Sep 17 00:00:00 2001 From: Beernaert Robbe Date: Tue, 8 Oct 2024 19:42:50 +0200 Subject: [PATCH 29/58] tried to cleanup projectElement function to extract the wpf sdk selection to new dedecated function! (global.json file writing not workin) --- modules/vstudio/vs2005_dotnetbase.lua | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/modules/vstudio/vs2005_dotnetbase.lua b/modules/vstudio/vs2005_dotnetbase.lua index 6da8f71ae3..daabcce416 100644 --- a/modules/vstudio/vs2005_dotnetbase.lua +++ b/modules/vstudio/vs2005_dotnetbase.lua @@ -57,11 +57,7 @@ function dotnetbase.projectElement(prj) if dotnetbase.isNewFormatProject(prj) then - if prj.flags.WPF then - _p('') - else - _p('',dotnetbase.netcore.getsdk(prj)) - end + _p('', dotnetbase.netcore.getsdk(prj)) else local ver = '' local action = p.action.current() @@ -821,8 +817,10 @@ end function dotnetbase.netcore.getsdk(cfg) - if not cfg.dotnetsdk then - return "Microsoft.NET.Sdk" + if cfg.flags.WP then + return nmap["windowsdesktop"] + elseif not cfg.dotnetsdk then + return "Microsoft.NET.Sdk" end local map = { ["web"] = "Microsoft.NET.Sdk.Web", @@ -833,12 +831,11 @@ ["mstest"] = "MSTest.Sdk", } return map[cfg.dotnetsdk] - end end function dotnetbase.netcore.dotnetsdk(cfg) if cfg.dotnetsdk == "mstest" then - _p(2,'') + io.writefile(cfg.workspace.location + "/global.json","{\"msbuild-sdks\": {\"MSTest.Sdk\": \"3.6.1\"}}") end end From b4093210e5bfc5a02d39d741e9d5177c7970fd7b Mon Sep 17 00:00:00 2001 From: Beernaert Robbe Date: Tue, 8 Oct 2024 19:59:45 +0200 Subject: [PATCH 30/58] put the api.register next to dotnetframework register function --- src/_premake_init.lua | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/_premake_init.lua b/src/_premake_init.lua index 5c265e4f41..03ad3c3c4b 100644 --- a/src/_premake_init.lua +++ b/src/_premake_init.lua @@ -618,6 +618,20 @@ kind = "string", } + api.register { + name = "dotnetsdk", + scope = "project", + kind = "string", + allowed = { + "web", + "razor", + "worker", + "blazor", + "windowsdesktop", + "mstest" + } + } + api.register { name = "enabledefaultcompileitems", scope = "config", @@ -772,20 +786,6 @@ kind = "string", } - api.register { - name = "dotnetsdk", - scope = "project", - kind = "string", - allowed = { - "web", - "razor", - "worker", - "blazor", - "windowsdesktop", - "mstest" - } - } - api.register { name = "cdialect", scope = "config", From 67b90c3a260e6c2378ac5f1b5080437da8b5a5a4 Mon Sep 17 00:00:00 2001 From: Beernaert Robbe Date: Tue, 8 Oct 2024 20:25:48 +0200 Subject: [PATCH 31/58] figured out the file logic also made it so it does not overwrite global.json when it already exists potentially overwriting variables --- modules/vstudio/vs2005_dotnetbase.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/vstudio/vs2005_dotnetbase.lua b/modules/vstudio/vs2005_dotnetbase.lua index daabcce416..cb6fed71f3 100644 --- a/modules/vstudio/vs2005_dotnetbase.lua +++ b/modules/vstudio/vs2005_dotnetbase.lua @@ -834,8 +834,9 @@ end function dotnetbase.netcore.dotnetsdk(cfg) - if cfg.dotnetsdk == "mstest" then - io.writefile(cfg.workspace.location + "/global.json","{\"msbuild-sdks\": {\"MSTest.Sdk\": \"3.6.1\"}}") + globalpath = string.format("%s/global.json",cfg.workspace.location) + if cfg.dotnetsdk == "mstest" and not os.isfile(globalpath) then + io.writefile(globalpath,"{\"msbuild-sdks\": {\"MSTest.Sdk\": \"3.6.1\"}}") end end From e0a4f80e4761953e8172cbf0a3a5da0f26541ca6 Mon Sep 17 00:00:00 2001 From: Beernaert Robbe Date: Wed, 9 Oct 2024 12:04:10 +0200 Subject: [PATCH 32/58] implemented feedback from samsinsane --- .../vstudio/tests/cs2005/test_dotnetsdk.lua | 98 +++++++++---------- modules/vstudio/vs2005_dotnetbase.lua | 27 ++--- src/_premake_init.lua | 13 +-- website/docs/dotnetsdk.md | 21 ++-- 4 files changed, 82 insertions(+), 77 deletions(-) diff --git a/modules/vstudio/tests/cs2005/test_dotnetsdk.lua b/modules/vstudio/tests/cs2005/test_dotnetsdk.lua index 75a9fb463a..6791a79d5e 100644 --- a/modules/vstudio/tests/cs2005/test_dotnetsdk.lua +++ b/modules/vstudio/tests/cs2005/test_dotnetsdk.lua @@ -1,6 +1,6 @@ -- -- tests/actions/vstudio/cs2005/test_dotnetsdk.lua --- Test DocumentationFile feature Visual Studio 2005+ C# project. +-- Test DotnetSDK feature Visual Studio 2005+ C# project. -- Copyright (c) 2012-2024 Jason Perkins and the Premake project -- local p = premake @@ -32,70 +32,70 @@ prj = test.getproject(wks, 1) end -function suite.testDefault() - prepare() - setConfig() + function suite.testDefault() + prepare() + setConfig() - test.capture [[ + test.capture [[ -]] -end + ]] + end -function suite.testWeb() - prepare() - dotnetsdk "web" - setConfig() + function suite.testWeb() + prepare() + dotnetsdk "web" + setConfig() - test.capture [[ + test.capture [[ - ]] -end + ]] + end -function suite.testRazor() - prepare() - dotnetsdk "razor" - setConfig() + function suite.testRazor() + prepare() + dotnetsdk "razor" + setConfig() - test.capture [[ + test.capture [[ - ]] -end + ]] + end -function suite.testWorker() - prepare() - dotnetsdk "worker" - setConfig() + function suite.testWorker() + prepare() + dotnetsdk "worker" + setConfig() - test.capture [[ + test.capture [[ - ]] -end + ]] + end -function suite.testBlazor() - prepare() - dotnetsdk "blazor" - setConfig() + function suite.testBlazor() + prepare() + dotnetsdk "blazor" + setConfig() - test.capture [[ + test.capture [[ - ]] -end + ]] + end -function suite.testWindowsDesktop() - prepare() - dotnetsdk "windowsdesktop" - setConfig() + function suite.testWindowsDesktop() + prepare() + dotnetsdk "windowsdesktop" + setConfig() - test.capture [[ + test.capture [[ - ]] -end -function suite.testMSTest() - prepare() - dotnetsdk "mstest" - setConfig() + ]] + end + function suite.testMSTest() + prepare() + dotnetsdk "mstest" + setConfig() - test.capture [[ + test.capture [[ - ]] -end + ]] + end diff --git a/modules/vstudio/vs2005_dotnetbase.lua b/modules/vstudio/vs2005_dotnetbase.lua index cb6fed71f3..2ebe2d9afc 100644 --- a/modules/vstudio/vs2005_dotnetbase.lua +++ b/modules/vstudio/vs2005_dotnetbase.lua @@ -817,26 +817,27 @@ end function dotnetbase.netcore.getsdk(cfg) + local map = { + ["Default"] = "Microsoft.NET.Sdk", + ["Web"] = "Microsoft.NET.Sdk.Web", + ["Razor"] = "Microsoft.NET.Sdk.Razor", + ["Worker"] = "Microsoft.NET.Sdk.Worker", + ["Blazor"] = "Microsoft.NET.Sdk.BlazorWebAssembly", + ["WindowsDesktop"] = "Microsoft.NET.Sdk.WindowsDesktop", + ["MSTest"] = "MSTest.Sdk", + } + if cfg.flags.WP then return nmap["windowsdesktop"] - elseif not cfg.dotnetsdk then - return "Microsoft.NET.Sdk" end - local map = { - ["web"] = "Microsoft.NET.Sdk.Web", - ["razor"] = "Microsoft.NET.Sdk.Razor", - ["worker"] = "Microsoft.NET.Sdk.Worker", - ["blazor"] = "Microsoft.NET.Sdk.BlazorWebAssembly", - ["windowsdesktop"] = "Microsoft.NET.Sdk.WindowsDesktop", - ["mstest"] = "MSTest.Sdk", - } - return map[cfg.dotnetsdk] + + return map[cfg.dotnetsdk or "Default"] end function dotnetbase.netcore.dotnetsdk(cfg) - globalpath = string.format("%s/global.json",cfg.workspace.location) + globalpath = string.format("%s/global.json", cfg.workspace.location) if cfg.dotnetsdk == "mstest" and not os.isfile(globalpath) then - io.writefile(globalpath,"{\"msbuild-sdks\": {\"MSTest.Sdk\": \"3.6.1\"}}") + io.writefile(globalpath, "{\"msbuild-sdks\": {\"MSTest.Sdk\": \"3.6.1\"}}") end end diff --git a/src/_premake_init.lua b/src/_premake_init.lua index 03ad3c3c4b..0331dbc718 100644 --- a/src/_premake_init.lua +++ b/src/_premake_init.lua @@ -623,12 +623,13 @@ scope = "project", kind = "string", allowed = { - "web", - "razor", - "worker", - "blazor", - "windowsdesktop", - "mstest" + "Default", + "Web", + "Razor", + "Worker", + "Blazor", + "WindowsDesktop", + "MSTest" } } diff --git a/website/docs/dotnetsdk.md b/website/docs/dotnetsdk.md index 5f17a4dd70..09ad5bd0ad 100644 --- a/website/docs/dotnetsdk.md +++ b/website/docs/dotnetsdk.md @@ -1,13 +1,14 @@ -Selects a .NET Sdk +Selects a .NET SDK ```lua -dotnetsdk "sdk" +dotnetsdk "SDK" ``` -[overview](https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview) +For more information see the MSDN documentation [here](https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview) ## parameters ## -`sdk` is one of +`SDK` is one of: + * [web](https://learn.microsoft.com/en-us/aspnet/core/razor-pages/web-sdk?toc=%2Fdotnet%2Fnavigate%2Ftools-diagnostics%2Ftoc.json&bc=%2Fdotnet%2Fbreadcrumb%2Ftoc.json) * [razor](https://learn.microsoft.com/en-us/aspnet/core/razor-pages/sdk?toc=%2Fdotnet%2Fnavigate%2Ftools-diagnostics%2Ftoc.json&bc=%2Fdotnet%2Fbreadcrumb%2Ftoc.json) * [worker](https://learn.microsoft.com/en-us/dotnet/core/extensions/workers) @@ -17,7 +18,7 @@ dotnetsdk "sdk" ## mstest ## -to make the MSTest sdk work you need to add the version to `global.json`: +To make the MSTest SDK work you need to add the version to `global.json`: ```json { "msbuild-sdks": { @@ -25,8 +26,12 @@ to make the MSTest sdk work you need to add the version to `global.json`: } } ``` +:::note +`global.json` will be auto generated when it does not exist! +::: + :::warning -`global.json` needs to be located in the same folder as your solution +`global.json` needs to be located in the same folder as your solution. ::: ### Applies To ### @@ -40,8 +45,6 @@ Premake 5.0 beta3 or later. Visual studio is the only toolset currently supported. ### Examples ### -use the web sdk - ```lua -dotnetsdk "web" +dotnetsdk "Web" ``` From 06ce5b6cc41e86733c63c0b9fca170bf3305d319 Mon Sep 17 00:00:00 2001 From: Beernaert Robbe Date: Wed, 9 Oct 2024 12:27:21 +0200 Subject: [PATCH 33/58] added a test for WPF flag --- .../vstudio/tests/cs2005/test_dotnetsdk.lua | 34 +++++++++++++++---- modules/vstudio/vs2005_dotnetbase.lua | 6 ++-- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/modules/vstudio/tests/cs2005/test_dotnetsdk.lua b/modules/vstudio/tests/cs2005/test_dotnetsdk.lua index 6791a79d5e..1ce4384ea7 100644 --- a/modules/vstudio/tests/cs2005/test_dotnetsdk.lua +++ b/modules/vstudio/tests/cs2005/test_dotnetsdk.lua @@ -32,7 +32,7 @@ prj = test.getproject(wks, 1) end - function suite.testDefault() + function suite.testNone() prepare() setConfig() @@ -41,9 +41,18 @@ ]] end + function suite.testDefault() + prepare() + setConfig() + dotnetsdk "Web" + test.capture [[ + + ]] + end + function suite.testWeb() prepare() - dotnetsdk "web" + dotnetsdk "Web" setConfig() test.capture [[ @@ -53,7 +62,7 @@ function suite.testRazor() prepare() - dotnetsdk "razor" + dotnetsdk "Razor" setConfig() test.capture [[ @@ -63,7 +72,7 @@ function suite.testWorker() prepare() - dotnetsdk "worker" + dotnetsdk "Worker" setConfig() test.capture [[ @@ -73,7 +82,7 @@ function suite.testBlazor() prepare() - dotnetsdk "blazor" + dotnetsdk "Blazor" setConfig() test.capture [[ @@ -83,7 +92,7 @@ function suite.testWindowsDesktop() prepare() - dotnetsdk "windowsdesktop" + dotnetsdk "WindowsDesktop" setConfig() test.capture [[ @@ -92,10 +101,21 @@ end function suite.testMSTest() prepare() - dotnetsdk "mstest" + dotnetsdk "MSTest" setConfig() test.capture [[ ]] end + + function suite.testWPFFlag() + prepare() + dotnetsdk "Web" + flags { "WPF" } + setConfig() + + test.capture [[ + + ]] + end diff --git a/modules/vstudio/vs2005_dotnetbase.lua b/modules/vstudio/vs2005_dotnetbase.lua index 2ebe2d9afc..1c75167729 100644 --- a/modules/vstudio/vs2005_dotnetbase.lua +++ b/modules/vstudio/vs2005_dotnetbase.lua @@ -827,15 +827,15 @@ ["MSTest"] = "MSTest.Sdk", } - if cfg.flags.WP then - return nmap["windowsdesktop"] + if cfg.flags.WPF then + return map["WindowsDesktop"] end return map[cfg.dotnetsdk or "Default"] end function dotnetbase.netcore.dotnetsdk(cfg) - globalpath = string.format("%s/global.json", cfg.workspace.location) + local globalpath = string.format("%s/global.json", cfg.workspace.location) if cfg.dotnetsdk == "mstest" and not os.isfile(globalpath) then io.writefile(globalpath, "{\"msbuild-sdks\": {\"MSTest.Sdk\": \"3.6.1\"}}") end From bff0fa978599d8402b7c4df9fbe283c48a3d7c98 Mon Sep 17 00:00:00 2001 From: Beernaert Robbe Date: Wed, 9 Oct 2024 12:33:29 +0200 Subject: [PATCH 34/58] updated the dotnetsk options in the docs --- website/docs/dotnetsdk.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/website/docs/dotnetsdk.md b/website/docs/dotnetsdk.md index 09ad5bd0ad..62be5e46b5 100644 --- a/website/docs/dotnetsdk.md +++ b/website/docs/dotnetsdk.md @@ -9,12 +9,12 @@ For more information see the MSDN documentation [here](https://learn.microsoft.c ## parameters ## `SDK` is one of: - * [web](https://learn.microsoft.com/en-us/aspnet/core/razor-pages/web-sdk?toc=%2Fdotnet%2Fnavigate%2Ftools-diagnostics%2Ftoc.json&bc=%2Fdotnet%2Fbreadcrumb%2Ftoc.json) - * [razor](https://learn.microsoft.com/en-us/aspnet/core/razor-pages/sdk?toc=%2Fdotnet%2Fnavigate%2Ftools-diagnostics%2Ftoc.json&bc=%2Fdotnet%2Fbreadcrumb%2Ftoc.json) - * [worker](https://learn.microsoft.com/en-us/dotnet/core/extensions/workers) - * [blazor](https://learn.microsoft.com/en-us/aspnet/core/blazor/) - * [windowsdesktop](https://learn.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props-desktop?view=aspnetcore-8.0) - * [mstest](https://learn.microsoft.com/en-us/dotnet/core/testing/unit-testing-mstest-sdk) + * [Web](https://learn.microsoft.com/en-us/aspnet/core/razor-pages/web-sdk?toc=%2Fdotnet%2Fnavigate%2Ftools-diagnostics%2Ftoc.json&bc=%2Fdotnet%2Fbreadcrumb%2Ftoc.json) + * [Razor](https://learn.microsoft.com/en-us/aspnet/core/razor-pages/sdk?toc=%2Fdotnet%2Fnavigate%2Ftools-diagnostics%2Ftoc.json&bc=%2Fdotnet%2Fbreadcrumb%2Ftoc.json) + * [Worker](https://learn.microsoft.com/en-us/dotnet/core/extensions/workers) + * [Blazor](https://learn.microsoft.com/en-us/aspnet/core/blazor/) + * [Windowsdesktop](https://learn.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props-desktop?view=aspnetcore-8.0) + * [MSTest](https://learn.microsoft.com/en-us/dotnet/core/testing/unit-testing-mstest-sdk) ## mstest ## From 3698bec814fffca6fbf7356e537d780584972e70 Mon Sep 17 00:00:00 2001 From: Beernaert Robbe Date: Wed, 9 Oct 2024 12:38:07 +0200 Subject: [PATCH 35/58] fixed WindowsDesktop type and added Default to docs --- website/docs/dotnetsdk.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/website/docs/dotnetsdk.md b/website/docs/dotnetsdk.md index 62be5e46b5..7beb2871f3 100644 --- a/website/docs/dotnetsdk.md +++ b/website/docs/dotnetsdk.md @@ -9,11 +9,12 @@ For more information see the MSDN documentation [here](https://learn.microsoft.c ## parameters ## `SDK` is one of: + * [Default](https://learn.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props) * [Web](https://learn.microsoft.com/en-us/aspnet/core/razor-pages/web-sdk?toc=%2Fdotnet%2Fnavigate%2Ftools-diagnostics%2Ftoc.json&bc=%2Fdotnet%2Fbreadcrumb%2Ftoc.json) * [Razor](https://learn.microsoft.com/en-us/aspnet/core/razor-pages/sdk?toc=%2Fdotnet%2Fnavigate%2Ftools-diagnostics%2Ftoc.json&bc=%2Fdotnet%2Fbreadcrumb%2Ftoc.json) * [Worker](https://learn.microsoft.com/en-us/dotnet/core/extensions/workers) * [Blazor](https://learn.microsoft.com/en-us/aspnet/core/blazor/) - * [Windowsdesktop](https://learn.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props-desktop?view=aspnetcore-8.0) + * [WindowsDesktop](https://learn.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props-desktop?view=aspnetcore-8.0) * [MSTest](https://learn.microsoft.com/en-us/dotnet/core/testing/unit-testing-mstest-sdk) From 566a587d3bac4e0976efa517e482c5275ed6e0bf Mon Sep 17 00:00:00 2001 From: Beernaert Robbe Date: Wed, 9 Oct 2024 15:17:15 +0200 Subject: [PATCH 36/58] implemented feedback from Jarod42 --- modules/vstudio/_preload.lua | 19 +++++++++++++++++-- modules/vstudio/vs2005_dotnetbase.lua | 6 +++--- src/_premake_init.lua | 15 --------------- website/docs/dotnetsdk.md | 17 +---------------- 4 files changed, 21 insertions(+), 36 deletions(-) diff --git a/modules/vstudio/_preload.lua b/modules/vstudio/_preload.lua index cb893b291c..dcf1d8f16f 100644 --- a/modules/vstudio/_preload.lua +++ b/modules/vstudio/_preload.lua @@ -65,7 +65,7 @@ "Hull", "Domain", "Compute", - "Library", + "Library", "Mesh", "Amplification", "Texture", @@ -255,7 +255,7 @@ scope = "config", kind = "string", } - + -- Relative per-project directory. Set to empty for the entire project to be copied as is -- Should default to empty really for the more seamless experience p.api.register { @@ -294,6 +294,21 @@ tokens = "true", } + p.api.register { + name = "dotnetsdk", + scope = "project", + kind = "string", + allowed = { + "Default", + "Web", + "Razor", + "Worker", + "Blazor", + "WindowsDesktop", + "MSTest" + } + } + -- -- Decide when the full module should be loaded. -- diff --git a/modules/vstudio/vs2005_dotnetbase.lua b/modules/vstudio/vs2005_dotnetbase.lua index 1c75167729..d01e85fea6 100644 --- a/modules/vstudio/vs2005_dotnetbase.lua +++ b/modules/vstudio/vs2005_dotnetbase.lua @@ -835,9 +835,9 @@ end function dotnetbase.netcore.dotnetsdk(cfg) - local globalpath = string.format("%s/global.json", cfg.workspace.location) - if cfg.dotnetsdk == "mstest" and not os.isfile(globalpath) then - io.writefile(globalpath, "{\"msbuild-sdks\": {\"MSTest.Sdk\": \"3.6.1\"}}") + local globalpath = path.join(cfg.workspace.location, "global.json") + if cfg.dotnetsdk == "MSTest" and not os.isfile(globalpath) then + io.writefile(globalpath, '{"msbuild-sdks": {"MSTest.Sdk": "3.6.1"}}') end end diff --git a/src/_premake_init.lua b/src/_premake_init.lua index 0331dbc718..6559639d69 100644 --- a/src/_premake_init.lua +++ b/src/_premake_init.lua @@ -618,21 +618,6 @@ kind = "string", } - api.register { - name = "dotnetsdk", - scope = "project", - kind = "string", - allowed = { - "Default", - "Web", - "Razor", - "Worker", - "Blazor", - "WindowsDesktop", - "MSTest" - } - } - api.register { name = "enabledefaultcompileitems", scope = "config", diff --git a/website/docs/dotnetsdk.md b/website/docs/dotnetsdk.md index 7beb2871f3..5dbc573308 100644 --- a/website/docs/dotnetsdk.md +++ b/website/docs/dotnetsdk.md @@ -19,22 +19,7 @@ For more information see the MSDN documentation [here](https://learn.microsoft.c ## mstest ## -To make the MSTest SDK work you need to add the version to `global.json`: -```json -{ - "msbuild-sdks": { - "MSTest.Sdk": "3.6.1" - } -} -``` -:::note -`global.json` will be auto generated when it does not exist! -::: - -:::warning -`global.json` needs to be located in the same folder as your solution. -::: - +SDK used for MSTest is `"3.6.1"`, to use another version create or update global.json near the solution. ### Applies To ### Project configurations. From 9fe25314f7f81caa4ef5719cbed0ed9096cfc231 Mon Sep 17 00:00:00 2001 From: Beernaert Robbe Date: Wed, 9 Oct 2024 18:11:18 +0200 Subject: [PATCH 37/58] added test but test is not fully correct because file is not written in test case but is written in normal ussage --- modules/vstudio/tests/cs2005/test_dotnetsdk.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/modules/vstudio/tests/cs2005/test_dotnetsdk.lua b/modules/vstudio/tests/cs2005/test_dotnetsdk.lua index 1ce4384ea7..0e20fd0719 100644 --- a/modules/vstudio/tests/cs2005/test_dotnetsdk.lua +++ b/modules/vstudio/tests/cs2005/test_dotnetsdk.lua @@ -99,6 +99,7 @@ ]] end + function suite.testMSTest() prepare() dotnetsdk "MSTest" @@ -119,3 +120,13 @@ ]] end + + function suite.testMSTestGlobalJson() + prepare() + dotnetsdk "MSTest" + setConfig() + + local globalpath = path.join(cfg.workspace.location, "global.json") + + test.istrue(os.isfile(globalpath)) + end From 1a25b9f9185fcfb0d258da89702bb645ce43ad14 Mon Sep 17 00:00:00 2001 From: Beernaert Robbe Date: Wed, 9 Oct 2024 22:29:18 +0200 Subject: [PATCH 38/58] at this point when running tests file creation is blocked i think because the file is created fine when using in non test environment! also tried changing dir to _TESTS_DIR to no avail. --- modules/vstudio/tests/cs2005/test_dotnetsdk.lua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/vstudio/tests/cs2005/test_dotnetsdk.lua b/modules/vstudio/tests/cs2005/test_dotnetsdk.lua index 0e20fd0719..b1c50076a5 100644 --- a/modules/vstudio/tests/cs2005/test_dotnetsdk.lua +++ b/modules/vstudio/tests/cs2005/test_dotnetsdk.lua @@ -10,12 +10,15 @@ -- Setup -- - local wks, prj + local wks, prj, cwd -- -- Setup and teardown -- function suite.setup() + cwd = os.getcwd() + os.chdir(_TESTS_DIR) + p.action.set("vs2010") wks = test.createWorkspace() configurations { "Debug", "Release" } @@ -23,6 +26,9 @@ dotnetframework "net8.0" end + function suite.teardown() + os.chdir(cwd) + end local function setConfig() local cfg = test.getconfig(prj, "Debug") dn2005.projectElement(cfg); @@ -125,8 +131,6 @@ prepare() dotnetsdk "MSTest" setConfig() - local globalpath = path.join(cfg.workspace.location, "global.json") - - test.istrue(os.isfile(globalpath)) + test.filecontains('{"msbuild-sdks": {"MSTest.Sdk": "3.6.1"}}',globalpath) end From d30ae4c7bd0297c4b542f26a2aa392ce720dc71d Mon Sep 17 00:00:00 2001 From: Beernaert Robbe Date: Thu, 10 Oct 2024 13:22:08 +0200 Subject: [PATCH 39/58] removed the global.json test and put a warning comment in the appropriate place as file writing is working --- modules/vstudio/tests/cs2005/test_dotnetsdk.lua | 8 -------- modules/vstudio/vs2005_dotnetbase.lua | 1 + 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/modules/vstudio/tests/cs2005/test_dotnetsdk.lua b/modules/vstudio/tests/cs2005/test_dotnetsdk.lua index b1c50076a5..4ca8737d2c 100644 --- a/modules/vstudio/tests/cs2005/test_dotnetsdk.lua +++ b/modules/vstudio/tests/cs2005/test_dotnetsdk.lua @@ -126,11 +126,3 @@ ]] end - - function suite.testMSTestGlobalJson() - prepare() - dotnetsdk "MSTest" - setConfig() - local globalpath = path.join(cfg.workspace.location, "global.json") - test.filecontains('{"msbuild-sdks": {"MSTest.Sdk": "3.6.1"}}',globalpath) - end diff --git a/modules/vstudio/vs2005_dotnetbase.lua b/modules/vstudio/vs2005_dotnetbase.lua index d01e85fea6..eec49334db 100644 --- a/modules/vstudio/vs2005_dotnetbase.lua +++ b/modules/vstudio/vs2005_dotnetbase.lua @@ -835,6 +835,7 @@ end function dotnetbase.netcore.dotnetsdk(cfg) + -- do not remove the file generation for global.json otherwise MSTest will not work!!! local globalpath = path.join(cfg.workspace.location, "global.json") if cfg.dotnetsdk == "MSTest" and not os.isfile(globalpath) then io.writefile(globalpath, '{"msbuild-sdks": {"MSTest.Sdk": "3.6.1"}}') From 31e560671548ad4bda23254738a69bf916c7821c Mon Sep 17 00:00:00 2001 From: Beernaert Robbe Date: Thu, 10 Oct 2024 18:13:25 +0200 Subject: [PATCH 40/58] premake.generate is kinda working as intended but the test part not so much! --- modules/vstudio/tests/cs2005/test_dotnetsdk.lua | 9 +++++++++ modules/vstudio/vs2005_dotnetbase.lua | 9 ++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/modules/vstudio/tests/cs2005/test_dotnetsdk.lua b/modules/vstudio/tests/cs2005/test_dotnetsdk.lua index 4ca8737d2c..ebb17a0533 100644 --- a/modules/vstudio/tests/cs2005/test_dotnetsdk.lua +++ b/modules/vstudio/tests/cs2005/test_dotnetsdk.lua @@ -126,3 +126,12 @@ ]] end + + function suite.testMSTestGlobalJSON() + prepare() + dotnetsdk "MSTest" + test.capture [[test]] + setConfig() + + + end diff --git a/modules/vstudio/vs2005_dotnetbase.lua b/modules/vstudio/vs2005_dotnetbase.lua index eec49334db..462ac1978b 100644 --- a/modules/vstudio/vs2005_dotnetbase.lua +++ b/modules/vstudio/vs2005_dotnetbase.lua @@ -838,7 +838,10 @@ -- do not remove the file generation for global.json otherwise MSTest will not work!!! local globalpath = path.join(cfg.workspace.location, "global.json") if cfg.dotnetsdk == "MSTest" and not os.isfile(globalpath) then - io.writefile(globalpath, '{"msbuild-sdks": {"MSTest.Sdk": "3.6.1"}}') + local content = p.capture(function() generate_global_json_content(prj) end) + if content ~= nil and #content > 0 then + p.generate(cfg.workspace, path.join(cfg.workspace.location,"global.json"), function() p.outln(content) end) + end end end @@ -847,3 +850,7 @@ _p(2,'true') end end + + function generate_global_json_content(cfg) + _p(0,'{"msbuild-sdks": {"MSTest.Sdk": "3.6.1"}}') + end From 6a8abbc8c3496ed835642c7845d069194bc4dbfc Mon Sep 17 00:00:00 2001 From: Beernaert Robbe Date: Thu, 10 Oct 2024 21:03:04 +0200 Subject: [PATCH 41/58] fixed the testMSTestGlobalJSON (thanks jarod for the help!) --- .../vstudio/tests/cs2005/test_dotnetsdk.lua | 10 +++++---- modules/vstudio/vs2005_dotnetbase.lua | 21 ++++++++++--------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/modules/vstudio/tests/cs2005/test_dotnetsdk.lua b/modules/vstudio/tests/cs2005/test_dotnetsdk.lua index ebb17a0533..bc614863b4 100644 --- a/modules/vstudio/tests/cs2005/test_dotnetsdk.lua +++ b/modules/vstudio/tests/cs2005/test_dotnetsdk.lua @@ -129,9 +129,11 @@ function suite.testMSTestGlobalJSON() prepare() - dotnetsdk "MSTest" - test.capture [[test]] - setConfig() - + local cfg = test.getconfig(prj, "Debug") + prj.dotnetsdk = "MSTest" + dn2005.output_global_json(prj) + test.capture[[ +{"msbuild-sdks": { "MSTest.Sdk": "3.6.1"}} + ]] end diff --git a/modules/vstudio/vs2005_dotnetbase.lua b/modules/vstudio/vs2005_dotnetbase.lua index 462ac1978b..dff05f186b 100644 --- a/modules/vstudio/vs2005_dotnetbase.lua +++ b/modules/vstudio/vs2005_dotnetbase.lua @@ -835,14 +835,7 @@ end function dotnetbase.netcore.dotnetsdk(cfg) - -- do not remove the file generation for global.json otherwise MSTest will not work!!! - local globalpath = path.join(cfg.workspace.location, "global.json") - if cfg.dotnetsdk == "MSTest" and not os.isfile(globalpath) then - local content = p.capture(function() generate_global_json_content(prj) end) - if content ~= nil and #content > 0 then - p.generate(cfg.workspace, path.join(cfg.workspace.location,"global.json"), function() p.outln(content) end) - end - end + dotnetbase.generate_global_json(cfg) end function dotnetbase.allowUnsafeBlocks(cfg) @@ -851,6 +844,14 @@ end end - function generate_global_json_content(cfg) - _p(0,'{"msbuild-sdks": {"MSTest.Sdk": "3.6.1"}}') + function dotnetbase.output_global_json(prj) -- unsure how you handle project with different config + if prj.dotnetsdk == "MSTest" then + _p('{"msbuild-sdks": {"MSTest.Sdk": "3.6.1"}}') + end + end + function dotnetbase.generate_global_json(prj) + local content = p.capture(function() dotnetbase.output_global_json(prj) end) + if content ~= nil and #content > 0 then + p.generate(prj, path.join(prj.workspace.location,"global.json"), function() p.outln(content) end) + end end From b36e1a0f4f1fbaa6c37cbad3536b6564eef736f8 Mon Sep 17 00:00:00 2001 From: Beernaert Robbe Date: Thu, 10 Oct 2024 21:04:36 +0200 Subject: [PATCH 42/58] fixed the indentation --- modules/vstudio/tests/cs2005/test_dotnetsdk.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/vstudio/tests/cs2005/test_dotnetsdk.lua b/modules/vstudio/tests/cs2005/test_dotnetsdk.lua index bc614863b4..68e8a5af7f 100644 --- a/modules/vstudio/tests/cs2005/test_dotnetsdk.lua +++ b/modules/vstudio/tests/cs2005/test_dotnetsdk.lua @@ -134,6 +134,6 @@ dn2005.output_global_json(prj) test.capture[[ {"msbuild-sdks": { "MSTest.Sdk": "3.6.1"}} - ]] + ]] end From 8f11868421e1812db16b75fbc1de55d415dcfdda Mon Sep 17 00:00:00 2001 From: Beernaert Robbe Date: Thu, 10 Oct 2024 21:08:55 +0200 Subject: [PATCH 43/58] forgot to fix the indentation --- modules/vstudio/tests/cs2005/test_dotnetsdk.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/vstudio/tests/cs2005/test_dotnetsdk.lua b/modules/vstudio/tests/cs2005/test_dotnetsdk.lua index 68e8a5af7f..2335e4282a 100644 --- a/modules/vstudio/tests/cs2005/test_dotnetsdk.lua +++ b/modules/vstudio/tests/cs2005/test_dotnetsdk.lua @@ -133,7 +133,7 @@ prj.dotnetsdk = "MSTest" dn2005.output_global_json(prj) test.capture[[ -{"msbuild-sdks": { "MSTest.Sdk": "3.6.1"}} +{"msbuild-sdks": {"MSTest.Sdk": "3.6.1"}} ]] end From 0243b8043f1b33f3d821d5482d52784ef86c516c Mon Sep 17 00:00:00 2001 From: Beernaert Robbe Date: Thu, 10 Oct 2024 21:35:49 +0200 Subject: [PATCH 44/58] made global.json look a bit better for endusers. --- modules/vstudio/tests/cs2005/test_dotnetsdk.lua | 7 ++++++- modules/vstudio/vs2005_dotnetbase.lua | 9 ++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/vstudio/tests/cs2005/test_dotnetsdk.lua b/modules/vstudio/tests/cs2005/test_dotnetsdk.lua index 2335e4282a..0c6cc2c7f4 100644 --- a/modules/vstudio/tests/cs2005/test_dotnetsdk.lua +++ b/modules/vstudio/tests/cs2005/test_dotnetsdk.lua @@ -133,7 +133,12 @@ prj.dotnetsdk = "MSTest" dn2005.output_global_json(prj) test.capture[[ -{"msbuild-sdks": {"MSTest.Sdk": "3.6.1"}} +{ + "msbuild-sdks": + { + "MSTest.Sdk": "3.6.1" + } +} ]] end diff --git a/modules/vstudio/vs2005_dotnetbase.lua b/modules/vstudio/vs2005_dotnetbase.lua index dff05f186b..b6640f2974 100644 --- a/modules/vstudio/vs2005_dotnetbase.lua +++ b/modules/vstudio/vs2005_dotnetbase.lua @@ -846,7 +846,14 @@ function dotnetbase.output_global_json(prj) -- unsure how you handle project with different config if prj.dotnetsdk == "MSTest" then - _p('{"msbuild-sdks": {"MSTest.Sdk": "3.6.1"}}') + _p([[ +{ + "msbuild-sdks": + { + "MSTest.Sdk": "3.6.1" + } +} + ]]) end end function dotnetbase.generate_global_json(prj) From 1338f3aef079d4bf2860e784998f59c86ab93ce9 Mon Sep 17 00:00:00 2001 From: Beernaert Robbe Date: Mon, 14 Oct 2024 12:09:20 +0200 Subject: [PATCH 45/58] the desired flow for global.json is working but the test is not working due to using p.generate twice! --- .../vstudio/tests/cs2005/test_dotnetsdk.lua | 20 +++++++++++++ modules/vstudio/vs2005_dotnetbase.lua | 30 +++++++++++-------- 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/modules/vstudio/tests/cs2005/test_dotnetsdk.lua b/modules/vstudio/tests/cs2005/test_dotnetsdk.lua index 0c6cc2c7f4..af80e7811b 100644 --- a/modules/vstudio/tests/cs2005/test_dotnetsdk.lua +++ b/modules/vstudio/tests/cs2005/test_dotnetsdk.lua @@ -140,5 +140,25 @@ } } ]] + end + function suite.testMSTestGlobalJSONExists() + prepare() + local cfg = test.getconfig(prj, "Debug") + prj.dotnetsdk = "MSTest" + p.generate(prj,path.join(prj.workspace.location, "global.json"), function() p.outln([[ +{ + "test:"testing" +} + ]]) end) + dn2005.output_global_json(prj) + test.capture[[ +{ + "test:"testing", + "msbuild-sdks": + { + "MSTest.Sdk": "3.6.1" + } +} + ]] end diff --git a/modules/vstudio/vs2005_dotnetbase.lua b/modules/vstudio/vs2005_dotnetbase.lua index b6640f2974..ae15844cf2 100644 --- a/modules/vstudio/vs2005_dotnetbase.lua +++ b/modules/vstudio/vs2005_dotnetbase.lua @@ -845,20 +845,24 @@ end function dotnetbase.output_global_json(prj) -- unsure how you handle project with different config - if prj.dotnetsdk == "MSTest" then - _p([[ -{ - "msbuild-sdks": - { - "MSTest.Sdk": "3.6.1" - } -} - ]]) + if prj.dotnetsdk == "MSTest" then + globaljson = json.decode(io.readfile(path.join(prj.workspace.location, "global.json"))) + if globaljson == nil then + globaljson = {} + globaljson["msbuild-sdks"] = {} + globaljson["msbuild-sdks"]["MSTest.Sdk"] = "3.6.1" + elseif globaljson["msbuild-sdks"] ~= nil then + globaljson["msbuild-sdks"]["MSTest.Sdk"] = "3.6.1" + else + globaljson["msbuild-sdks"] = {} + globaljson["msbuild-sdks"]["MSTest.Sdk"] = "3.6.1" + end + _p(json.encode(globaljson)) end end function dotnetbase.generate_global_json(prj) - local content = p.capture(function() dotnetbase.output_global_json(prj) end) - if content ~= nil and #content > 0 then - p.generate(prj, path.join(prj.workspace.location,"global.json"), function() p.outln(content) end) - end + local content = p.capture(function() dotnetbase.output_global_json(prj) end) + if content ~= nil and #content > 0 then + p.generate(prj, path.join(prj.workspace.location, "global.json"), function() p.outln(content) end) + end end From e17721fe282bfbf8e6a9c51ee7fa2aba629b0973 Mon Sep 17 00:00:00 2001 From: Beernaert Robbe Date: Mon, 14 Oct 2024 14:40:45 +0200 Subject: [PATCH 46/58] implemented feedback from jarod --- .../vstudio/tests/cs2005/test_dotnetsdk.lua | 21 ------------------- modules/vstudio/vs2005_dotnetbase.lua | 15 ++++--------- 2 files changed, 4 insertions(+), 32 deletions(-) diff --git a/modules/vstudio/tests/cs2005/test_dotnetsdk.lua b/modules/vstudio/tests/cs2005/test_dotnetsdk.lua index af80e7811b..c1206251e7 100644 --- a/modules/vstudio/tests/cs2005/test_dotnetsdk.lua +++ b/modules/vstudio/tests/cs2005/test_dotnetsdk.lua @@ -141,24 +141,3 @@ } ]] end - - function suite.testMSTestGlobalJSONExists() - prepare() - local cfg = test.getconfig(prj, "Debug") - prj.dotnetsdk = "MSTest" - p.generate(prj,path.join(prj.workspace.location, "global.json"), function() p.outln([[ -{ - "test:"testing" -} - ]]) end) - dn2005.output_global_json(prj) - test.capture[[ -{ - "test:"testing", - "msbuild-sdks": - { - "MSTest.Sdk": "3.6.1" - } -} - ]] - end diff --git a/modules/vstudio/vs2005_dotnetbase.lua b/modules/vstudio/vs2005_dotnetbase.lua index ae15844cf2..2c34e43c4a 100644 --- a/modules/vstudio/vs2005_dotnetbase.lua +++ b/modules/vstudio/vs2005_dotnetbase.lua @@ -844,19 +844,12 @@ end end - function dotnetbase.output_global_json(prj) -- unsure how you handle project with different config + function dotnetbase.output_global_json(prj) if prj.dotnetsdk == "MSTest" then globaljson = json.decode(io.readfile(path.join(prj.workspace.location, "global.json"))) - if globaljson == nil then - globaljson = {} - globaljson["msbuild-sdks"] = {} - globaljson["msbuild-sdks"]["MSTest.Sdk"] = "3.6.1" - elseif globaljson["msbuild-sdks"] ~= nil then - globaljson["msbuild-sdks"]["MSTest.Sdk"] = "3.6.1" - else - globaljson["msbuild-sdks"] = {} - globaljson["msbuild-sdks"]["MSTest.Sdk"] = "3.6.1" - end + globaljson = globaljson or {} + globaljson["msbuild-sdks"] = globaljson["msbuild-sdks"] or {} + globaljson["msbuild-sdks"]["MSTest.Sdk"] = "3.6.1" _p(json.encode(globaljson)) end end From 32cba9ebab155d7b0c3dbea7eb28212e52dcfff1 Mon Sep 17 00:00:00 2001 From: Beernaert Robbe Date: Mon, 14 Oct 2024 22:40:23 +0200 Subject: [PATCH 47/58] fixed thr broken global.json test --- .../vstudio/tests/cs2005/test_dotnetsdk.lua | 18 ++++++++++-------- modules/vstudio/vs2005_dotnetbase.lua | 4 ++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/modules/vstudio/tests/cs2005/test_dotnetsdk.lua b/modules/vstudio/tests/cs2005/test_dotnetsdk.lua index c1206251e7..51aa8642f3 100644 --- a/modules/vstudio/tests/cs2005/test_dotnetsdk.lua +++ b/modules/vstudio/tests/cs2005/test_dotnetsdk.lua @@ -132,12 +132,14 @@ local cfg = test.getconfig(prj, "Debug") prj.dotnetsdk = "MSTest" dn2005.output_global_json(prj) - test.capture[[ -{ - "msbuild-sdks": - { - "MSTest.Sdk": "3.6.1" - } -} - ]] + test.capture[[{"msbuild-sdks":{"MSTest.Sdk": "3.6.1"}}]] + end + + function suite.testMSTestGlobalJSONExists() + prepare() + local cfg = test.getconfig(prj, "Debug") + prj.dotnetsdk = "MSTest" + p.generate(prj, path.join(prj.workspace.location, "global.json"), function() p.outln('{"test":"global"') end) + dn2005.output_global_json(prj) + test.capture[[{"test":"global","msbuild-sdks":{"MSTest.Sdk": "3.6.1"}}]] end diff --git a/modules/vstudio/vs2005_dotnetbase.lua b/modules/vstudio/vs2005_dotnetbase.lua index 2c34e43c4a..7a5dc6c9e7 100644 --- a/modules/vstudio/vs2005_dotnetbase.lua +++ b/modules/vstudio/vs2005_dotnetbase.lua @@ -846,10 +846,10 @@ function dotnetbase.output_global_json(prj) if prj.dotnetsdk == "MSTest" then - globaljson = json.decode(io.readfile(path.join(prj.workspace.location, "global.json"))) - globaljson = globaljson or {} + local globaljson = json.decode(io.readfile(path.join(prj.workspace.location, "global.json"))) or {} globaljson["msbuild-sdks"] = globaljson["msbuild-sdks"] or {} globaljson["msbuild-sdks"]["MSTest.Sdk"] = "3.6.1" + _p(json.encode(globaljson)) end end From 1c81c864bb04f59f17688a776160fb524db9ecb4 Mon Sep 17 00:00:00 2001 From: Beernaert Robbe Date: Thu, 21 Nov 2024 18:27:07 +0100 Subject: [PATCH 48/58] updated dotnetsdk to now accept version localy and removed global.json file generation --- modules/vstudio/_preload.lua | 40 ++++++++--- .../vstudio/tests/cs2005/test_dotnetsdk.lua | 71 +++++++++++++++---- modules/vstudio/vs2005_dotnetbase.lua | 45 ++++++------ 3 files changed, 110 insertions(+), 46 deletions(-) diff --git a/modules/vstudio/_preload.lua b/modules/vstudio/_preload.lua index cfe8b26039..bd099fc9a5 100644 --- a/modules/vstudio/_preload.lua +++ b/modules/vstudio/_preload.lua @@ -298,15 +298,37 @@ name = "dotnetsdk", scope = "project", kind = "string", - allowed = { - "Default", - "Web", - "Razor", - "Worker", - "Blazor", - "WindowsDesktop", - "MSTest" - } + allowed = function (value) + -- value is expected to be in the format / + local parts = value:explode("/", true, 1) + local sdk = parts[1] or value + local allowedSdks = { + "Default", + "Web", + "Razor", + "Worker", + "Blazor", + "WindowsDesktop", + "MSTest" + } + -- Only perform the check when a version is provided to avoid infinite recursing. + -- Check that the specified sdk is in the allowed list + for _, allowed in ipairs(allowedSdks) do + if sdk == allowed then + return value + end + end + + -- The specified sdk is not recognized + if parts and #parts == 2 then + if sdk and sdk:match("^[%w%-]+$") then + return value + end + end + + return nil +end + } -- diff --git a/modules/vstudio/tests/cs2005/test_dotnetsdk.lua b/modules/vstudio/tests/cs2005/test_dotnetsdk.lua index 51aa8642f3..a98ceeed6c 100644 --- a/modules/vstudio/tests/cs2005/test_dotnetsdk.lua +++ b/modules/vstudio/tests/cs2005/test_dotnetsdk.lua @@ -50,7 +50,7 @@ function suite.testDefault() prepare() setConfig() - dotnetsdk "Web" + dotnetsdk "Default" test.capture [[ ]] @@ -108,11 +108,11 @@ function suite.testMSTest() prepare() - dotnetsdk "MSTest" + dotnetsdk "MSTest/3.4.0" setConfig() test.capture [[ - + ]] end @@ -127,19 +127,62 @@ ]] end - function suite.testMSTestGlobalJSON() + function suite.testWebVersion() prepare() - local cfg = test.getconfig(prj, "Debug") - prj.dotnetsdk = "MSTest" - dn2005.output_global_json(prj) - test.capture[[{"msbuild-sdks":{"MSTest.Sdk": "3.6.1"}}]] + dotnetsdk "Web/3.4.0" + setConfig() + + test.capture [[ + + ]] end - function suite.testMSTestGlobalJSONExists() + function suite.testRazorVersion() prepare() - local cfg = test.getconfig(prj, "Debug") - prj.dotnetsdk = "MSTest" - p.generate(prj, path.join(prj.workspace.location, "global.json"), function() p.outln('{"test":"global"') end) - dn2005.output_global_json(prj) - test.capture[[{"test":"global","msbuild-sdks":{"MSTest.Sdk": "3.6.1"}}]] + dotnetsdk "Razor/3.4.0" + setConfig() + + test.capture [[ + + ]] + end + + function suite.testWorkerVersion() + prepare() + dotnetsdk "Worker/3.4.0" + setConfig() + + test.capture [[ + + ]] + end + + function suite.testBlazorVersion() + prepare() + dotnetsdk "Blazor/3.4.0" + setConfig() + + test.capture [[ + + ]] + end + + function suite.testWindowsDesktopVersion() + prepare() + dotnetsdk "WindowsDesktop/3.4.0" + setConfig() + + test.capture [[ + + ]] + end + + function suite.testCustomSDKVersion() + prepare() + dotnetsdk "CustomSdk/3.4.0" + setConfig() + + test.capture [[ + + ]] end diff --git a/modules/vstudio/vs2005_dotnetbase.lua b/modules/vstudio/vs2005_dotnetbase.lua index fc2bf043b8..920a19df15 100644 --- a/modules/vstudio/vs2005_dotnetbase.lua +++ b/modules/vstudio/vs2005_dotnetbase.lua @@ -826,16 +826,31 @@ ["WindowsDesktop"] = "Microsoft.NET.Sdk.WindowsDesktop", ["MSTest"] = "MSTest.Sdk", } + local parts = nil + if cfg.dotnetsdk then + parts = cfg.dotnetsdk:explode("/", true, 1) + end - if cfg.flags.WPF then - return map["WindowsDesktop"] - end + local sdk = (parts and #parts > 0 and parts[1]) or cfg.dotnetsdk + if not parts or #parts < 2 then + -- prioritize WPF flag for compatibility + if cfg.flags.WPF then + return map["WindowsDesktop"] + end - return map[cfg.dotnetsdk or "Default"] - end + if sdk == "MSTest" then + -- If sdk is MSTest, we need exactly 2 parts + p.error("MSTest requires a version to be specified!") + return nil + end + + return map[sdk or "Default"] - function dotnetbase.netcore.dotnetsdk(cfg) - dotnetbase.generate_global_json(cfg) + elseif parts and #parts == 2 then + return string.format("%s/%s",map[parts[1]] or parts[1],parts[2]) + end + + return map["Default"] end function dotnetbase.allowUnsafeBlocks(cfg) @@ -843,19 +858,3 @@ _p(2,'true') end end - - function dotnetbase.output_global_json(prj) - if prj.dotnetsdk == "MSTest" then - local globaljson = json.decode(io.readfile(path.join(prj.workspace.location, "global.json"))) or {} - globaljson["msbuild-sdks"] = globaljson["msbuild-sdks"] or {} - globaljson["msbuild-sdks"]["MSTest.Sdk"] = "3.6.1" - - _p(json.encode(globaljson)) - end - end - function dotnetbase.generate_global_json(prj) - local content = p.capture(function() dotnetbase.output_global_json(prj) end) - if content ~= nil and #content > 0 then - p.generate(prj, path.join(prj.workspace.location, "global.json"), function() p.outln(content) end) - end - end From 8099d0f4e513672771b025b45e016bb61f778fd1 Mon Sep 17 00:00:00 2001 From: Beernaert Robbe Date: Thu, 21 Nov 2024 18:34:21 +0100 Subject: [PATCH 49/58] updated docs --- website/docs/dotnetsdk.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/website/docs/dotnetsdk.md b/website/docs/dotnetsdk.md index 5dbc573308..cf32b91ac6 100644 --- a/website/docs/dotnetsdk.md +++ b/website/docs/dotnetsdk.md @@ -19,14 +19,14 @@ For more information see the MSDN documentation [here](https://learn.microsoft.c ## mstest ## -SDK used for MSTest is `"3.6.1"`, to use another version create or update global.json near the solution. +when using MSTest sdk a version has to be specified! ### Applies To ### Project configurations. ### Availability ### -Premake 5.0 beta3 or later. +Premake 5.0 beta4 or later. Visual studio is the only toolset currently supported. @@ -34,3 +34,7 @@ Visual studio is the only toolset currently supported. ```lua dotnetsdk "Web" ``` + +```lua +dotnetsdk "Web/3.4.0" +``` From c76940b8a9018f0e0702625281740d512b76dc4b Mon Sep 17 00:00:00 2001 From: Beernaert Robbe Date: Thu, 21 Nov 2024 18:43:53 +0100 Subject: [PATCH 50/58] fixed code formating! --- modules/vstudio/vs2005_dotnetbase.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/vstudio/vs2005_dotnetbase.lua b/modules/vstudio/vs2005_dotnetbase.lua index 920a19df15..1ffeaae965 100644 --- a/modules/vstudio/vs2005_dotnetbase.lua +++ b/modules/vstudio/vs2005_dotnetbase.lua @@ -826,14 +826,16 @@ ["WindowsDesktop"] = "Microsoft.NET.Sdk.WindowsDesktop", ["MSTest"] = "MSTest.Sdk", } + local parts = nil + if cfg.dotnetsdk then parts = cfg.dotnetsdk:explode("/", true, 1) end local sdk = (parts and #parts > 0 and parts[1]) or cfg.dotnetsdk if not parts or #parts < 2 then - -- prioritize WPF flag for compatibility + -- prioritize WPF flag for compatibility, remove if statement when cfg.flags api is deprecated if cfg.flags.WPF then return map["WindowsDesktop"] end @@ -847,9 +849,9 @@ return map[sdk or "Default"] elseif parts and #parts == 2 then - return string.format("%s/%s",map[parts[1]] or parts[1],parts[2]) + return string.format("%s/%s", map[parts[1]] or parts[1], parts[2]) end - + return map["Default"] end From 06ee29ef1b726ad83ba81c7de465138959f556f9 Mon Sep 17 00:00:00 2001 From: Beernaert Robbe Date: Mon, 25 Nov 2024 11:32:38 +0100 Subject: [PATCH 51/58] added dynamicvallidator type to api.lua --- modules/vstudio/_preload.lua | 54 +++++++++++++++--------------------- src/base/api.lua | 6 +++- 2 files changed, 28 insertions(+), 32 deletions(-) diff --git a/modules/vstudio/_preload.lua b/modules/vstudio/_preload.lua index bd099fc9a5..96155b1de4 100644 --- a/modules/vstudio/_preload.lua +++ b/modules/vstudio/_preload.lua @@ -298,37 +298,29 @@ name = "dotnetsdk", scope = "project", kind = "string", - allowed = function (value) - -- value is expected to be in the format / - local parts = value:explode("/", true, 1) - local sdk = parts[1] or value - local allowedSdks = { - "Default", - "Web", - "Razor", - "Worker", - "Blazor", - "WindowsDesktop", - "MSTest" - } - -- Only perform the check when a version is provided to avoid infinite recursing. - -- Check that the specified sdk is in the allowed list - for _, allowed in ipairs(allowedSdks) do - if sdk == allowed then - return value - end - end - - -- The specified sdk is not recognized - if parts and #parts == 2 then - if sdk and sdk:match("^[%w%-]+$") then - return value - end - end - - return nil -end - + allowed = { + "Default", + "Web", + "Razor", + "Worker", + "Blazor", + "WindowsDesktop", + "MSTest", + function (value,kind) + -- value is expected to be in the format / + local parts = value:explode("/", true, 1) + local sdk = parts[1] or value + + + if parts and #parts == 2 then + if p.api.checkValue(p.field.get("dotnetsdk", parts[1], "string")) then + return value + end + end + + return nil + end, + } } -- diff --git a/src/base/api.lua b/src/base/api.lua index 1c822eca0a..f6c91d2ccf 100755 --- a/src/base/api.lua +++ b/src/base/api.lua @@ -265,7 +265,11 @@ if type(field.allowed) == "table" then for i, item in ipairs(field.allowed) do - field.allowed[item:lower()] = item + if(type(item) == "function") then + field.allowed["dynamicvalidator"] = item + else + field.allowed[item:lower()] = item + end end end From 4b0eb5a435ceb9b32593142aafdf5a784d86f18b Mon Sep 17 00:00:00 2001 From: Beernaert Robbe Date: Mon, 25 Nov 2024 14:03:24 +0100 Subject: [PATCH 52/58] the dynamicvallidator function is working now --- modules/vstudio/_preload.lua | 4 ++-- modules/vstudio/tests/cs2005/test_dotnetsdk.lua | 8 +------- modules/vstudio/vs2005_dotnetbase.lua | 14 +------------- src/_premake_init.lua | 9 +++++++++ 4 files changed, 13 insertions(+), 22 deletions(-) diff --git a/modules/vstudio/_preload.lua b/modules/vstudio/_preload.lua index 96155b1de4..d3e5540742 100644 --- a/modules/vstudio/_preload.lua +++ b/modules/vstudio/_preload.lua @@ -306,14 +306,14 @@ "Blazor", "WindowsDesktop", "MSTest", - function (value,kind) + function (value) -- value is expected to be in the format / local parts = value:explode("/", true, 1) local sdk = parts[1] or value if parts and #parts == 2 then - if p.api.checkValue(p.field.get("dotnetsdk", parts[1], "string")) then + if p.api.checkValue(p.field.get("dotnetsdk"), parts[1],"string") then return value end end diff --git a/modules/vstudio/tests/cs2005/test_dotnetsdk.lua b/modules/vstudio/tests/cs2005/test_dotnetsdk.lua index a98ceeed6c..09e824ce88 100644 --- a/modules/vstudio/tests/cs2005/test_dotnetsdk.lua +++ b/modules/vstudio/tests/cs2005/test_dotnetsdk.lua @@ -16,9 +16,6 @@ -- Setup and teardown -- function suite.setup() - cwd = os.getcwd() - os.chdir(_TESTS_DIR) - p.action.set("vs2010") wks = test.createWorkspace() configurations { "Debug", "Release" } @@ -26,9 +23,6 @@ dotnetframework "net8.0" end - function suite.teardown() - os.chdir(cwd) - end local function setConfig() local cfg = test.getconfig(prj, "Debug") dn2005.projectElement(cfg); @@ -118,7 +112,6 @@ function suite.testWPFFlag() prepare() - dotnetsdk "Web" flags { "WPF" } setConfig() @@ -179,6 +172,7 @@ function suite.testCustomSDKVersion() prepare() + premake.api.addAllowed("dotnetsdk", "CustomSdk") dotnetsdk "CustomSdk/3.4.0" setConfig() diff --git a/modules/vstudio/vs2005_dotnetbase.lua b/modules/vstudio/vs2005_dotnetbase.lua index 1ffeaae965..b215f7b4d4 100644 --- a/modules/vstudio/vs2005_dotnetbase.lua +++ b/modules/vstudio/vs2005_dotnetbase.lua @@ -826,7 +826,7 @@ ["WindowsDesktop"] = "Microsoft.NET.Sdk.WindowsDesktop", ["MSTest"] = "MSTest.Sdk", } - + local parts = nil if cfg.dotnetsdk then @@ -835,19 +835,7 @@ local sdk = (parts and #parts > 0 and parts[1]) or cfg.dotnetsdk if not parts or #parts < 2 then - -- prioritize WPF flag for compatibility, remove if statement when cfg.flags api is deprecated - if cfg.flags.WPF then - return map["WindowsDesktop"] - end - - if sdk == "MSTest" then - -- If sdk is MSTest, we need exactly 2 parts - p.error("MSTest requires a version to be specified!") - return nil - end - return map[sdk or "Default"] - elseif parts and #parts == 2 then return string.format("%s/%s", map[parts[1]] or parts[1], parts[2]) end diff --git a/src/_premake_init.lua b/src/_premake_init.lua index 09985eb923..988f9e6500 100644 --- a/src/_premake_init.lua +++ b/src/_premake_init.lua @@ -1798,6 +1798,15 @@ omitframepointer("Default") end) + --25 November 2024 + api.deprecateValue("flags", "WPF", 'Use `dotnetsdk "WindowsDesktop"` instead.', + function(value) + dotnetsdk "WindowsDesktop" + end, + function(value) + dotnetsdk "Default" + end) + ----------------------------------------------------------------------------- -- -- Install Premake's default set of command line arguments. From 1cdac64e0546a8c7e73ef33fc4012a62de33f383 Mon Sep 17 00:00:00 2001 From: Beernaert Robbe Date: Mon, 25 Nov 2024 14:06:14 +0100 Subject: [PATCH 53/58] updated documentation to show how to add custom sdk's --- website/docs/dotnetsdk.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/website/docs/dotnetsdk.md b/website/docs/dotnetsdk.md index cf32b91ac6..fbcf049bbb 100644 --- a/website/docs/dotnetsdk.md +++ b/website/docs/dotnetsdk.md @@ -37,4 +37,16 @@ dotnetsdk "Web" ```lua dotnetsdk "Web/3.4.0" + +``` +## CustomSDK + +```lua +premake.api.addAllowed("dotnetsdk", "CustomSDK") -- add the customSDK to allowed values for dotnetsdk +dotnetsdk "CustomSDK/3.4.0" +``` + +```lua +premake.api.addAllowed("dotnetsdk", "CustomSDK") -- add the customSDK to allowed values for dotnetsdk +dotnetsdk "CustomSDK" ``` From cc6c8aebee221aabef2111950dfe1dc0d303aa43 Mon Sep 17 00:00:00 2001 From: Beernaert Robbe Date: Mon, 25 Nov 2024 14:18:13 +0100 Subject: [PATCH 54/58] deprecated WPF flag --- src/_premake_init.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/_premake_init.lua b/src/_premake_init.lua index 6127a16d23..67388d1aee 100644 --- a/src/_premake_init.lua +++ b/src/_premake_init.lua @@ -355,12 +355,20 @@ "RelativeLinks", "ShadowedVariables", "UndefinedIdentifiers", - "WPF", + "WPF", -- DEPRECATED }, aliases = { FatalWarnings = { "FatalWarnings", "FatalCompileWarnings", "FatalLinkWarnings" }, }, } + --25 November 2024 + api.deprecateValue("flags", "WPF", 'Use `dotnetsdk "WindowsDesktop"` instead.', + function(value) + dotnetsdk "WindowsDesktop" + end, + function(value) + dotnetsdk "Default" + end) api.register { name = "floatingpoint", From ff88efc12c18d46e49bdf2ebf1f84b4b2ee690a4 Mon Sep 17 00:00:00 2001 From: lolrobbe2 <90089980+lolrobbe2@users.noreply.github.com> Date: Mon, 25 Nov 2024 14:35:19 +0100 Subject: [PATCH 55/58] removed cwd Co-authored-by: Joris Dauphin --- modules/vstudio/tests/cs2005/test_dotnetsdk.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/vstudio/tests/cs2005/test_dotnetsdk.lua b/modules/vstudio/tests/cs2005/test_dotnetsdk.lua index 09e824ce88..6a3a98cf57 100644 --- a/modules/vstudio/tests/cs2005/test_dotnetsdk.lua +++ b/modules/vstudio/tests/cs2005/test_dotnetsdk.lua @@ -10,7 +10,7 @@ -- Setup -- - local wks, prj, cwd + local wks, prj -- -- Setup and teardown From e7070567225526ba04bab45793cae646997f01e8 Mon Sep 17 00:00:00 2001 From: Beernaert Robbe Date: Fri, 3 Jan 2025 16:00:10 +0100 Subject: [PATCH 56/58] this made it work and supports multiple functions. maby obfuscate the key a bit more. --- modules/vstudio/_preload.lua | 2 +- src/base/api.lua | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/vstudio/_preload.lua b/modules/vstudio/_preload.lua index 573a8df53a..70b80e6e58 100644 --- a/modules/vstudio/_preload.lua +++ b/modules/vstudio/_preload.lua @@ -633,7 +633,7 @@ end return nil - end, + end } } diff --git a/src/base/api.lua b/src/base/api.lua index f6c91d2ccf..9ba8257707 100755 --- a/src/base/api.lua +++ b/src/base/api.lua @@ -265,11 +265,11 @@ if type(field.allowed) == "table" then for i, item in ipairs(field.allowed) do - if(type(item) == "function") then - field.allowed["dynamicvalidator"] = item - else - field.allowed[item:lower()] = item - end + if type(item) == "string" then + field.allowed[item:lower()] = item + elseif type(item) == "function" then + field.allowed["_function_" .. i .."_"] = item + end end end From 9c7f6e4e00940c4fb9eb78e6dcda882d9e4d14ec Mon Sep 17 00:00:00 2001 From: Beernaert Robbe Date: Sun, 5 Jan 2025 14:07:35 +0100 Subject: [PATCH 57/58] things suddenly seem to work --- modules/vstudio/tests/cs2005/test_dotnetsdk.lua | 2 +- src/base/api.lua | 2 -- website/docs/dotnetsdk.md | 4 ++-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/modules/vstudio/tests/cs2005/test_dotnetsdk.lua b/modules/vstudio/tests/cs2005/test_dotnetsdk.lua index 6a3a98cf57..18e9dfab6b 100644 --- a/modules/vstudio/tests/cs2005/test_dotnetsdk.lua +++ b/modules/vstudio/tests/cs2005/test_dotnetsdk.lua @@ -1,7 +1,7 @@ -- -- tests/actions/vstudio/cs2005/test_dotnetsdk.lua -- Test DotnetSDK feature Visual Studio 2005+ C# project. --- Copyright (c) 2012-2024 Jason Perkins and the Premake project +-- Copyright (c) 2012-2025 Jason Perkins and the Premake project -- local p = premake local suite = test.declare("vstudio_cs2005_dotnetsdk") diff --git a/src/base/api.lua b/src/base/api.lua index 2eebd016a8..ff04a382f9 100755 --- a/src/base/api.lua +++ b/src/base/api.lua @@ -267,8 +267,6 @@ for i, item in ipairs(field.allowed) do if type(item) == "string" then field.allowed[item:lower()] = item - elseif type(item) == "function" then - field.allowed["_function_" .. i .."_"] = item end end end diff --git a/website/docs/dotnetsdk.md b/website/docs/dotnetsdk.md index c787c0d163..ad75b386f2 100644 --- a/website/docs/dotnetsdk.md +++ b/website/docs/dotnetsdk.md @@ -6,7 +6,7 @@ dotnetsdk "SDK" For more information see the MSDN documentation [here](https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview) -## parameters ## +## Parameters ## `SDK` is one of: * [Default](https://learn.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props) @@ -23,7 +23,7 @@ Project configurations. ### Availability ### -Premake 5.0 beta4 or later. +Premake 5.0 beta5 or later. Visual studio is the only toolset currently supported. From 6223a4b5c03cbdba68bdb2e00c9dc503ff1e32e7 Mon Sep 17 00:00:00 2001 From: Beernaert Robbe Date: Tue, 7 Jan 2025 08:28:18 +0100 Subject: [PATCH 58/58] removed unused code --- modules/vstudio/_preload.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/vstudio/_preload.lua b/modules/vstudio/_preload.lua index 305c307f25..5a7cdb8e0d 100644 --- a/modules/vstudio/_preload.lua +++ b/modules/vstudio/_preload.lua @@ -623,8 +623,6 @@ function (value) -- value is expected to be in the format / local parts = value:explode("/", true, 1) - local sdk = parts[1] or value - if parts and #parts == 2 then if p.api.checkValue(p.field.get("dotnetsdk"), parts[1], "string") then