Skip to content

[Bug]: Breaks with multiple framework targets #92

@ds5678

Description

@ds5678

On a brand new project with this csproj file, everything compiles fine:

<Project Sdk="Microsoft.NET.Sdk">

	<PropertyGroup>
		<TargetFramework>netstandard2.0</TargetFramework>
	</PropertyGroup>

	<ItemGroup>
		<PackageReference Include="TunnelVisionLabs.ReferenceAssemblyAnnotator" Version="1.0.0-alpha.160" PrivateAssets="all" />

		<!-- Specifies the version of Microsoft.NETCore.App.Ref to obtain nullability information from. -->
		<PackageDownload Include="Microsoft.NETCore.App.Ref" Version="[6.0.0]" />
	</ItemGroup>

</Project>

However, if the csproj file is changed slightly, it no longer does:

<Project Sdk="Microsoft.NET.Sdk">

	<PropertyGroup>
		<TargetFrameworks>netstandard2.0</TargetFrameworks>
	</PropertyGroup>

	<ItemGroup>
		<PackageReference Include="TunnelVisionLabs.ReferenceAssemblyAnnotator" Version="1.0.0-alpha.160" PrivateAssets="all" />

		<!-- Specifies the version of Microsoft.NETCore.App.Ref to obtain nullability information from. -->
		<PackageDownload Include="Microsoft.NETCore.App.Ref" Version="[6.0.0]" />
	</ItemGroup>

</Project>

In Visual Studio 2022, I get this error:

MSB4184	The expression """.Substring(1)" cannot be evaluated. startIndex cannot be larger than length of string. Parameter name: startIndex

This points to a line in TunnelVisionLabs.ReferenceAssemblyAnnotator.targets:

<PropertyGroup Condition="'$(TargetFrameworkVersion.Substring(1))' &gt;= '2.0'">

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions