Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve templates #2338

Merged
merged 7 commits into from
Jul 1, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 14 additions & 4 deletions templates/install-from-source.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
dotnet build -c Release BenchmarkDotNet.Templates.csproj
dotnet pack -c Release BenchmarkDotNet.Templates.csproj
dotnet new -u BenchmarkDotNet.Templates
dotnet new -i BenchmarkDotNet.Templates::0.0.0-* --nuget-source .\bin\Release\
:: Run only from the folder where the batch file is located!

dotnet build BenchmarkDotNet.Templates.csproj -c Release
dotnet pack BenchmarkDotNet.Templates.csproj -c Release

:: If we install the templates via a folder path, then it will have a different ID (ID=folder path).
:: It will conflict with BDN templates from nuget.
:: We need to install the templates via a FILE path in order to update the template from nuget.
::
:: https://stackoverflow.com/questions/47450531/batch-write-output-of-dir-to-a-variable
for /f "delims=" %%a in ('dir /s /b BenchmarkDotNet.Templates*.nupkg') do set "nupkg_path=%%a"

dotnet new --uninstall "BenchmarkDotNet.Templates"
dotnet new --install "%nupkg_path%"
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,54 @@
},
"framework": {
"type": "parameter",
"datatype": "string",
"description": "The target framework for the project (e.g. netstandard2.0). Default \"net5.0\" if \"--console-app\" is true, \"netstandard2.0\" if \"--console-app\" is false",
"description": "The target framework for the project.",
"datatype": "choice",
"choices": [
{
"choice": "net8.0",
"description": ".NET 8"
},
{
"choice": "net7.0",
"description": ".NET 7"
},
{
"choice": "net6.0",
"description": ".NET 6"
},
{
"choice": "netstandard2.1",
"description": ".NET Standard 2.1"
},
{
"choice": "netstandard2.0",
"description": ".NET Standard 2.0"
},
{
"choice": "net481",
"description": ".NET Framework 4.8.1"
},
{
"choice": "net48",
"description": ".NET Framework 4.8"
},
{
"choice": "net472",
"description": ".NET Framework 4.7.2"
},
{
"choice": "net471",
"description": ".NET Framework 4.7.1"
},
{
"choice": "net47",
"description": ".NET Framework 4.7"
},
{
"choice": "net462",
"description": ".NET Framework 4.6.2"
}
],
"defaultValue": ""
},
"frameworkDefault": {
Expand All @@ -45,7 +91,7 @@
"cases": [
{
"condition": "(framework == '' && consoleApp == true)",
"value": "net5.0"
"value": "net6.0"
},
{
"condition": "(framework == '' && consoleApp == false)",
Expand Down Expand Up @@ -98,7 +144,7 @@
"type": "parameter",
"datatype": "string",
"description": "Version of BenchmarkDotNet that will be referenced.",
"defaultValue": "0.12.1",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With each new release, you need to change this manually.

Currently, if you add BDN.Templates, a project will be created with BDN v0.12.1.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I try to handle this issue – #1879
@AndreyAkinshin could you take a look please ?

"defaultValue": "0.13.5",
"replaces": "$(BenchmarkDotNetVersion)"
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Running;

namespace _BenchmarkProjectName_
Expand All @@ -6,7 +7,11 @@ public class Program
{
public static void Main(string[] args)
{
var summary = BenchmarkRunner.Run<$(BenchmarkName)>();
var config = DefaultConfig.Instance;
var summary = BenchmarkRunner.Run<$(BenchmarkName)>(config, args);

// Use this to select benchmarks from the console:
// var summaries = BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args, config);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,54 @@
},
"framework": {
"type": "parameter",
"datatype": "string",
"description": "The target framework for the project (e.g. netstandard2.0). Default \"net5.0\" if \"--console-app\" is true, \"netstandard2.0\" if \"--console-app\" is false",
"description": "The target framework for the project.",
"datatype": "choice",
"choices": [
{
"choice": "net8.0",
"description": ".NET 8"
},
{
"choice": "net7.0",
"description": ".NET 7"
},
{
"choice": "net6.0",
"description": ".NET 6"
},
{
"choice": "netstandard2.1",
"description": ".NET Standard 2.1"
},
{
"choice": "netstandard2.0",
"description": ".NET Standard 2.0"
},
{
"choice": "net481",
"description": ".NET Framework 4.8.1"
},
{
"choice": "net48",
"description": ".NET Framework 4.8"
},
{
"choice": "net472",
"description": ".NET Framework 4.7.2"
},
{
"choice": "net471",
"description": ".NET Framework 4.7.1"
},
{
"choice": "net47",
"description": ".NET Framework 4.7"
},
{
"choice": "net462",
"description": ".NET Framework 4.6.2"
}
],
"defaultValue": ""
},
"frameworkDefault": {
Expand All @@ -45,7 +91,7 @@
"cases": [
{
"condition": "(framework == '' && consoleApp == true)",
"value": "net5.0"
"value": "net6.0"
},
{
"condition": "(framework == '' && consoleApp == false)",
Expand Down Expand Up @@ -98,7 +144,7 @@
"type": "parameter",
"datatype": "string",
"description": "Version of BenchmarkDotNet that will be referenced.",
"defaultValue": "0.12.1",
"defaultValue": "0.13.5",
"replaces": "$(BenchmarkDotNetVersion)"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,54 @@
},
"framework": {
"type": "parameter",
"datatype": "string",
"description": "The target framework for the project (e.g. netstandard2.0). Default \"net5.0\" if \"--console-app\" is true, \"netstandard2.0\" if \"--console-app\" is false",
"description": "The target framework for the project.",
"datatype": "choice",
"choices": [
{
"choice": "net8.0",
"description": ".NET 8"
},
{
"choice": "net7.0",
"description": ".NET 7"
},
{
"choice": "net6.0",
"description": ".NET 6"
},
{
"choice": "netstandard2.1",
"description": ".NET Standard 2.1"
},
{
"choice": "netstandard2.0",
"description": ".NET Standard 2.0"
},
{
"choice": "net481",
"description": ".NET Framework 4.8.1"
},
{
"choice": "net48",
"description": ".NET Framework 4.8"
},
{
"choice": "net472",
"description": ".NET Framework 4.7.2"
},
{
"choice": "net471",
"description": ".NET Framework 4.7.1"
},
{
"choice": "net47",
"description": ".NET Framework 4.7"
},
{
"choice": "net462",
"description": ".NET Framework 4.6.2"
}
],
"defaultValue": ""
},
"frameworkDefault": {
Expand All @@ -45,7 +91,7 @@
"cases": [
{
"condition": "(framework == '' && consoleApp == true)",
"value": "net5.0"
"value": "net6.0"
},
{
"condition": "(framework == '' && consoleApp == false)",
Expand Down Expand Up @@ -98,7 +144,7 @@
"type": "parameter",
"datatype": "string",
"description": "Version of BenchmarkDotNet that will be referenced.",
"defaultValue": "0.12.1",
"defaultValue": "0.13.5",
"replaces": "$(BenchmarkDotNetVersion)"
}
},
Expand Down