Skip to content
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

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

Open
sharpzilla opened this issue Aug 20, 2024 · 0 comments
Labels

Comments

@sharpzilla
Copy link

sharpzilla commented Aug 20, 2024

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 sharpzilla added the bug label Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant