refit icon indicating copy to clipboard operation
refit copied to clipboard

[Bug]: dotnet build with Directory.Build.props can't build source generated code

Open sharpzilla opened this issue 1 year ago • 0 comments

Describe the bug 🐞

There is an issue when I'm trying to use the file Directory.Build.props with PropertyGroup:

 <RootNamespace>$(SolutionName).$(MSBuildProjectName)</RootNamespace>

It's crucial that the building process from the IDE works. However, something goes wrong with the dotnet build command. When I delete that line from the build props, the build from the PowerShell command line works fine.

Step to reproduce

  1. Create a project named Worker.
  2. Create a project named Application.
  3. Add a reference to the Application project in Worker project.
  4. In the solution root folder, create a Directory.Build.props file.
  5. Use Visual Studio to build or press F5. The build is successful.
  6. Go to powershell and use dotnet build. An error occured

Expected behavior

dotnet build should build as usual build process in IDE.

IDE

Visual Studio 2022

Operating system

Windows

Version

10

Device

Laptop

Refit Version

7.1.2

Additional information ℹ️

Directory.Build.props content:

<Project>
  <PropertyGroup>
	  <RootNamespace>$(SolutionName).$(MSBuildProjectName)</RootNamespace>
  </PropertyGroup>
</Project>

Build errors:

Build FAILED.
C:\Users\Sharpzilla\source\MySolution\src\Application\obj\Debug\net8.0\InterfaceStubGeneratorV2\Refit.Generator.InterfaceStubGeneratorV2\PreserveAttribute.g.cs(3,11): error CS1001: Identifier expected
 [C:\Users\Sharpzilla\source\MySolution\src\Application\Application.csproj]
C:\Users\Sharpzilla\source\MySolution\src\Application\obj\Debug\net8.0\InterfaceStubGeneratorV2\Refit.Generator.InterfaceStubGeneratorV2\Generated.g.cs(9,14): error CS1001: Identifier expected [C:\Use
rs\Sharpzilla\source\MySolution\src\Application\Application.csproj]
C:\Users\Sharpzilla\source\MySolution\src\Application\obj\Debug\net8.0\InterfaceStubGeneratorV2\Refit.Generator.InterfaceStubGeneratorV2\IFreshFitnessApiClient.g.cs(12,14): error CS1001: Identifier ex
pected [C:\Users\Sharpzilla\source\MySolution\src\Application\Application.csproj]
    0 Warning(s)
    3 Error(s)

sharpzilla avatar Aug 20 '24 12:08 sharpzilla