adjust defaultBenchmarkDotNetVersion on build (#1879)

* adjust defaultBenchmarkDotNetVersion on build

* fix https://github.com/dotnet/BenchmarkDotNet/pull/1879#discussion_r1250960415

* fix https://github.com/dotnet/BenchmarkDotNet/pull/1879#discussion_r1250961663

* fix https://github.com/dotnet/BenchmarkDotNet/pull/1879#discussion_r1250963754

* add install-from-source.sh (for macOS for example)

* fix copy paste
This commit is contained in:
askazakov 2023-07-04 15:26:26 +05:00 коммит произвёл GitHub
Родитель 609e484edd
Коммит c4debeabe8
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 58 добавлений и 0 удалений

Просмотреть файл

@ -62,4 +62,28 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<UsingTask TaskName="ReplaceFileText"
TaskFactory="RoslynCodeTaskFactory"
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<InputFilename ParameterType="System.String" Required="true" />
<OutputFilename ParameterType="System.String" Required="true" />
<MatchExpression ParameterType="System.String" Required="true" />
<ReplacementText ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Using Namespace="System" />
<Using Namespace="System.IO" />
<Using Namespace="System.Text.RegularExpressions" />
<Code Type="Fragment" Language="cs">
<![CDATA[
File.WriteAllText(
OutputFilename,
Regex.Replace(File.ReadAllText(InputFilename), MatchExpression, ReplacementText)
);
]]>
</Code>
</Task>
</UsingTask>
</Project>

Просмотреть файл

@ -24,4 +24,25 @@
<Compile Remove="**\*" />
<None Remove="*.bat;.sh" />
</ItemGroup>
<Target Name="Fix BenchmarkDotNetVersion"
BeforeTargets="Build">
<ReplaceFileText
InputFilename="templates/BenchmarkDotNet.BenchmarkProjectTemplate.CSharp/.template.config/template.json"
OutputFilename="templates/BenchmarkDotNet.BenchmarkProjectTemplate.CSharp/.template.config/template.json"
MatchExpression='("defaultValue": )"([\d+\.?]+)"'
ReplacementText='${1}"$(VersionPrefix)"' />
<ReplaceFileText
InputFilename="templates/BenchmarkDotNet.BenchmarkProjectTemplate.FSharp/.template.config/template.json"
OutputFilename="templates/BenchmarkDotNet.BenchmarkProjectTemplate.FSharp/.template.config/template.json"
MatchExpression='("defaultValue": )"([\d+\.?]+)"'
ReplacementText='${1}"$(VersionPrefix)"' />
<ReplaceFileText
InputFilename="templates/BenchmarkDotNet.BenchmarkProjectTemplate.VB/.template.config/template.json"
OutputFilename="templates/BenchmarkDotNet.BenchmarkProjectTemplate.VB/.template.config/template.json"
MatchExpression='("defaultValue": )"([\d+\.?]+)"'
ReplacementText='${1}"$(VersionPrefix)"' />
</Target>
</Project>

Просмотреть файл

@ -0,0 +1,13 @@
# Run only from the folder where the shell script 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.
nupkg_path=$(find . -name "BenchmarkDotNet.Templates*.nupkg")
dotnet new uninstall "BenchmarkDotNet.Templates"
dotnet new install $nupkg_path