Azure/azure-functions-core-tools

func start does not honor Directory.Build.props when using $(SolutionDir)

Open

#4,230 opened on Jan 13, 2025

 (2 comments) (0 reactions) (0 assignees)C# (491 forks)auto 404
buggood first issue

Repository metrics

Stars
 (1,456 stars)
PR merge metrics
 (PR metrics pending)

Description

Version

4.0.6610

Description

A project which correctly builds and starts with func start, would fails in the presence of a Directory.Build.props containing $(SolutionDir), like in:

<Project>
  <PropertyGroup>
    <UseArtifactsOutput>true</UseArtifactsOutput>
    <ArtifactsPath>$(SolutionDir)/.build</ArtifactsPath>
  </PropertyGroup>
</Project>

Steps to reproduce

  • cd in the directory of a C# Azure Function source code
  • Add a file Directory.Build.props containing $(SolutionDir), like in:
<Project>
  <PropertyGroup>
    <UseArtifactsOutput>true</UseArtifactsOutput>
    <ArtifactsPath>$(SolutionDir)/.build</ArtifactsPath>
  </PropertyGroup>
</Project>
  • Run func start
  • Expected behavior: success
  • Actual result:
  Determining projects to restore...
  Restored C:\prg\batch-server\service-bus\src\CSharpAzureFunction\CSharpAzureFunction.csproj (in 309 ms).
CSC : error CS2007: Unrecognized option: '/.build\obj\CSharpAzureFunction\debug\CSharpAzureFunction.GlobalUsings.g.cs' [C:\prg\batch-server\service-bus\src\CSharpAzureFunction\CSharpAzureFunction.csproj]

Error building project
CSC : error CS2007: Unrecognized option: '/.build\obj\CSharpAzureFunction\debug\.NETCoreApp,Version=v9.0.AssemblyAttributes.cs' [C:\prg\batch-server\service-bus\src\CSharpAzureFunction\CSharpAzureFunction.csproj]
CSC : error CS2007: Unrecognized option: '/.build\obj\CSharpAzureFunction\debug\CSharpAzureFunction.AssemblyInfo.cs' [C:\prg\batch-server\service-bus\src\CSharpAzureFunction\CSharpAzureFunction.csproj]

Build FAILED.

CSC : error CS2007: Unrecognized option: '/.build\obj\CSharpAzureFunction\debug\CSharpAzureFunction.GlobalUsings.g.cs' [C:\prg\batch-server\service-bus\src\CSharpAzureFunction\CSharpAzureFunction.csproj]
CSC : error CS2007: Unrecognized option: '/.build\obj\CSharpAzureFunction\debug\.NETCoreApp,Version=v9.0.AssemblyAttributes.cs' [C:\prg\batch-server\service-bus\src\CSharpAzureFunction\CSharpAzureFunction.csproj]
CSC : error CS2007: Unrecognized option: '/.build\obj\CSharpAzureFunction\debug\CSharpAzureFunction.AssemblyInfo.cs' [C:\prg\batch-server\service-bus\src\CSharpAzureFunction\CSharpAzureFunction.csproj]

Build succeeds in case either an absolute or a relative path is used, instead of $(SolutionDir).

Contributor guide