Skip to content

Unable to use variables for PackageReferences after #2347 #2369

@cincuranet

Description

@cincuranet

Now that package references are copied into generated csproj (#2347), using variables there results in failure, because the variable is not available there.

One way to make it fail:

  • Create a console app with some benchmarks.
  • Use this as a csproj (note the SomeVersion variable).
<Project Sdk="Microsoft.NET.Sdk">
	<PropertyGroup>
		<OutputType>Exe</OutputType>
		<TargetFramework>net7.0</TargetFramework>
		<ImplicitUsings>enable</ImplicitUsings>
		<Nullable>enable</Nullable>
	</PropertyGroup>
	<PropertyGroup>
		<SomeVersion>5.1.1</SomeVersion>
	</PropertyGroup>
	<ItemGroup>
		<PackageReference Include="BenchmarkDotNet" Version="0.13.7-nightly.20230713.34" />
		<PackageReference Include="Microsoft.Data.SqlClient" Version="$(SomeVersion)" />
	</ItemGroup>
</Project>

Program.cs for completenes.

using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;

namespace ConsoleApp1
{
    internal class Program
    {
        static void Main(string[] args)
        {
            BenchmarkRunner.Run<Demo>();
        }
    }

    [ShortRunJob]
    public class Demo
    {
        [Benchmark]
        public void FooBar()
        {
            Microsoft.Data.SqlClient.SqlConnection.ClearAllPools();
        }
    }
}

#2364 and #2295 seem to have same root cause as this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions