Skip to content

Unable to use variables for PackageReferences after #2347 #2369

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

Closed
cincuranet opened this issue Jul 14, 2023 · 1 comment · Fixed by #2365
Closed

Unable to use variables for PackageReferences after #2347 #2369

cincuranet opened this issue Jul 14, 2023 · 1 comment · Fixed by #2365
Milestone

Comments

@cincuranet
Copy link
Contributor

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.

@timcassell
Copy link
Collaborator

#2295 Is unrelated, as that was reported before we started copying PackageReferences. #2364 is indeed the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants