Aspire: Cannot Build Solution: Multiple Issues Encountered (Java Requirement, NU1008 Error)
Describe the bug
I attempted to build the solution to contribute to the project but encountered several blocking issues. These issues make it difficult to proceed, especially as they are not documented in the contribution guidelines.
Regression
Not applicable. This is my first attempt to build the solution.
Steps to reproduce
- Clone the repository.
- Follow the provided steps in the README or contribution guide to set up the solution.
- Run dotnet build to build the solution.
### Issues Encountered
#### 1. Test Build Error
- **Test**: `CommunityToolkit.Aspire.Hosting.EventStore.Tests.EventStoreResourceCtorShouldThrowWhenNameIsNull`
- **Line**: 113
- **Error**: `const string name = null!;`
#### 2. Maven/Java Build Error
- **Project File**: `CommunityToolkit.Aspire.Hosting.Java.AppHost` in `examples`.
- **Error**:
<Target Name="PublishRunMaven" AfterTargets="Build">
<Exec WorkingDirectory="$(JavaAppRoot)" Command="./mvnw --quiet clean package" />
</Target>
- The error suggests a Java/Maven requirement (`"./mvnw --quiet clean package" exited with code 1`), but this is not mentioned in the setup instructions. I commented this out to try progressing further.
#### 3. NU1008 Central Package Versioning Error
- **Error**:
Projects that use central package version management should not define the version on the PackageReference items but on the PackageVersion items.
- **Packages Affected**:
- OpenTelemetry.Instrumentation.AspNetCore
- OpenTelemetry.Exporter.OpenTelemetryProtocol
- OpenTelemetry.Instrumentation.Runtime
- Microsoft.Extensions.Http.Resilience
- Microsoft.Extensions.ServiceDiscovery
- OpenTelemetry.Extensions.Hosting
- OpenTelemetry.Instrumentation.Http
- **Project**: `CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder.ServiceDefaults`
Expected behavior
The solution should build successfully following the provided setup instructions, enabling contributors to proceed with contributions.
Screenshots
IDE and version
VS 2022, Rider
IDE version
VS:17.12.2, Rider: 2024.3
Nuget packages
Additional context
I’ve spent around 2 hours troubleshooting these issues but have been unable to progress. The build issues are unexpected and undocumented, making it hard for new contributors to get started. Please advise on the following:
-Should I install Java/Maven for this project?
- Is there an official approach for resolving the NU1008 errors?
- Any suggestions for bypassing the build errors in the examples projects to allow contributions?
Help us help you
Yes, I’d like to be assigned to work on this item
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 42 (34 by maintainers)
I’m sorry that you’ve had a difficult time setting up a machine for developing against the toolkit. We did invest initially in what we thought would be a good contributors guide, but reviewing it again it’s clear that the path to the “setup your machine” is not as discoverable as it could be.
I’ve created https://github.com/CommunityToolkit/Aspire/pull/314 which improves the discoverability (and does some updates to the guide).
Due to the complexity of the integrations we support, there are a lot of runtimes required, and Java + Maven is one such example.
I’m unsure as to why you’re hitting NU1008, unless you’ve modified a csproj to include a
<PackageReferencenode that also includes a version. Here’s how the csproj looks for the project referenced in the issue: https://github.com/CommunityToolkit/Aspire/blob/2ef1ba97b2820ea244bafb0b858caec13fef3b6e/examples/data-api-builder/CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder.ServiceDefaults/CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder.ServiceDefaults.csproj#L9-L17We don’t include a version on the references to the packages, as the version is dictated by the
Directory.Packages.propsfile in the repo root, ensuring that we are using consistent versions across all packages.Ok. I enabled it and it now works. I still don’t know why it was disabled in the first place… Anyway, thank you very much @aaronpowell
Doing some testing, the only way I can reproduce this is by disabling the nuget.org source in the
nuget.configfile that we have in the repo (ie - removing the addition of the source).@Odonno - what do you get when you run
dotnet nuget list sourcein the repo root? It should look like this: