Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions build/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -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>
21 changes: 21 additions & 0 deletions templates/BenchmarkDotNet.Templates.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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>
13 changes: 13 additions & 0 deletions templates/install-from-source.sh
Original file line number Diff line number Diff line change
@@ -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