Skip to content

MSB3755 using Windows path separators for Task References on macOS #12085

@jeremy-visionaid

Description

@jeremy-visionaid

Issue Description

Using Windows path separators in a Reference element within a Task does not appear to get normalized and fails with MSB3755

Steps to Reproduce

Based on https://learn.microsoft.com/en-us/visualstudio/msbuild/walkthrough-creating-an-inline-task?view=vs-2022 but adding a Reference:

	<UsingTask TaskName="Adder" TaskFactory="RoslynCodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
		<ParameterGroup>
			<A ParameterType="System.Int32" Required="true" />
			<B ParameterType="System.Int32" Required="true" />
			<C ParameterType="System.Int32" Output="true" />
		</ParameterGroup>

		<Task>
			<Reference Include="$(NugetPackageRoot)microsoft.bcl.asyncinterfaces\9.0.6\lib\netstandard2.0\Microsoft.Bcl.AsyncInterfaces.dll" />
			<Code Type="Fragment" Language="cs">
				C = A + B;
			</Code>
		</Task>
	</UsingTask>

	<Target Name="TestBuild" BeforeTargets="CopyFilesToOutputDirectory" DependsOnTargets="BuildOnlySettings">
		<Adder A="4" B="5">
			<Output PropertyName="Sum" TaskParameter="C" />
		</Adder>
		<Message Text="The sum is $(Sum)" Importance="High" />
	</Target>

Expected Behavior

Builds and runs OK

Actual Behavior

error MSB3755: Could not find reference "/Users/user/.nuget/packages/\microsoft.bcl.asyncinterfaces\9.0.6\lib\netstandard2.0\Microsoft.Bcl.AsyncInterfaces.dll". If this reference is required by your code, you may get compilation errors.

Analysis

As a workaround, using forward slash works on both Windows and macOS

Versions & Configurations

MSBuild 16.10.1.51301
dotnet SDK 9.0.301

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: EngineIssues impacting the core execution of targets and tasks.backlogtriaged

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions