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

Cannot Build Solution: Multiple Issues Encountered (Java Requirement, NU1008 Error) #309

Open
terle opened this issue Dec 3, 2024 · 27 comments
Labels
documentation Improvements or additions to documentation

Comments

@terle
Copy link

terle commented Dec 3, 2024

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

Image
Image

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

@aaronpowell
Copy link
Member

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 #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 <PackageReference node that also includes a version. Here's how the csproj looks for the project referenced in the issue:

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Http.Resilience" />
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" />
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" />
</ItemGroup>

We don't include a version on the references to the packages, as the version is dictated by the Directory.Packages.props file in the repo root, ensuring that we are using consistent versions across all packages.

@Odonno
Copy link

Odonno commented Dec 7, 2024

I just pulled the latest version from main branch and I am unable to work on the project. The dotnet restore step always fail. I cleaned the nuget local cache but the error persist with now failing on every package. I see no reason why this task could fail.

Image

Some information that can help:

.NET SDK:
 Version:           9.0.100
 Commit:            59db016f11
 Workload version:  9.0.100-manifests.c6f19616
 MSBuild version:   17.12.7+5b8665660

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22631
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\9.0.100\

.NET workloads installed:
 [aspire]
   Installation Source: VS 17.12.35506.116
   Manifest Version:    8.2.2/8.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.aspire\8.2.2\WorkloadManifest.json
   Install Type:              Msi

Configured to use loose manifests when installing new manifests.

Host:
  Version:      9.0.0
  Architecture: x64
  Commit:       9d5a6a9aa4

.NET SDKs installed:
  3.1.426 [C:\Program Files\dotnet\sdk]
  6.0.321 [C:\Program Files\dotnet\sdk]
  9.0.100-rc.2.24474.11 [C:\Program Files\dotnet\sdk]
  9.0.100 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.26 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 9.0.0-rc.2.24474.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.26 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 9.0.0-rc.2.24473.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.26 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 9.0.0-rc.2.24474.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  C:\GitHub\AspireToolkit\global.json

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

@terle
Copy link
Author

terle commented Dec 7, 2024

I just pulled the latest version from main branch and I am unable to work on the project. The dotnet restore step always fail.

I suggest you read in PR (#334) from above, it hasn't yet been merged into main. Aaron has created a great instruction on how to get it setup, that might help you forward.

@Odonno
Copy link

Odonno commented Dec 7, 2024

I suppose you meant #314 ? I read the PR and I saw nothing that could fix my issue.

I already contributed to this project before and it worked just fine. Including the dotnet restore as it is the first step before doing anything... I tried to set the default framework to net9.0 but the errors are still present, only half of them of course (net8.0 being out of the equation).

For your issue regarding the requirements to have npm or Java or any other tool installed, I think you can unload the projects that trigger this issue. I don't remember having this issue but unloading a project should allow you to compile the entire project without error.

@Odonno
Copy link

Odonno commented Dec 7, 2024

Anf for the other error, @aaronpowell already explained why NU1008 happens.

@aaronpowell
Copy link
Member

@Odonno the logs seem to suggest that the error is it can't find .NET 8, and I don't see it listed as an installed SDK.

Can you verify if you have the .NET 8 SDK installed?

@Odonno
Copy link

Odonno commented Dec 7, 2024

I reinstalled .NET 8. Still the same issue.

If you clean your nuget local cache and try a dotnet restore on your machine, does it work?

@aaronpowell
Copy link
Member

I've just cloned onto a new machine and ran dotnet nuget locals all --clean and then dotnet restore and it worked without an issue. I tried the same on a fresh devcontainer setup (rebuilt the container in VS Code) and dotnet restore worked.

Can you capture the whole output of the dotnet restore command (dotnet restore >> restore.log) and provide that?

@aaronpowell aaronpowell added the documentation Improvements or additions to documentation label Dec 7, 2024
@aaronpowell
Copy link
Member

@terle - were you able to progress with the improved instructions in #314?

@Odonno
Copy link

Odonno commented Dec 7, 2024

I've just cloned onto a new machine and ran dotnet nuget locals all --clean and then dotnet restore and it worked without an issue. I tried the same on a fresh devcontainer setup (rebuilt the container in VS Code) and dotnet restore worked.

Can you capture the whole output of the dotnet restore command (dotnet restore >> restore.log) and provide that?

restore.log

@aaronpowell
Copy link
Member

I'm pretty stumped, I'll have to do some more investigation into what might be the problem. The log seems to suggest that it can't find the packages on nuget.org, or that it's not even trying to look at nuget.org.

I can see that it's aware of the nuget.config file and it's skipping dotnet-eng that is defined there for most packages, which it should do, but the nuget.config defines that the alternative source is nuget.org, which is then failing for you for some reason.

@terle
Copy link
Author

terle commented Dec 8, 2024

@terle - were you able to progress with the improved instructions in #314?

Yes, your setup-instructions to use VS Code and DevContainers helped a lot :)
I ran into another issue when building, logs spews out a lot of these:

StreamJsonRpc.RemoteInvocationException: Request nominateProject failed with message: Cannot read properties of undefined (reading 'size')
   at StreamJsonRpc.JsonRpc.InvokeCoreAsync[TResult](RequestId id, String targetName, IReadOnlyList`1 arguments, IReadOnlyList`1 positionalArgumentDeclaredTypes, IReadOnlyDictionary`2 namedArgumentDeclaredTypes, CancellationToken cancellationToken, Boolean isParameterObject)
   at Microsoft.VisualStudio.ProjectSystem.PackageReferences.NuGetRestoreService.NominateAsync(ProjectRestoreInfo restoreData, IReadOnlyCollection`1 inputVersions, CancellationToken cancellationToken)

And tells me to contact the maintainers. Here is file: ProjectSystemServerFault_cf2ef281-b6f1-4bab-b0a8-20de4e38e766.failure.txt

If it helps @Odonno and you, I did dotnet nuget locals all --clear and dotnet restore >> restore.log on my machine, and it seemed to work: restore.log

@aaronpowell
Copy link
Member

@terle - were you able to progress with the improved instructions in #314?

Yes, your setup-instructions to use VS Code and DevContainers helped a lot :) I ran into another issue when building, logs spews out a lot of these:

StreamJsonRpc.RemoteInvocationException: Request nominateProject failed with message: Cannot read properties of undefined (reading 'size')
at StreamJsonRpc.JsonRpc.InvokeCoreAsync[TResult](RequestId id, String targetName, IReadOnlyList1 arguments, IReadOnlyList1 positionalArgumentDeclaredTypes, IReadOnlyDictionary2 namedArgumentDeclaredTypes, CancellationToken cancellationToken, Boolean isParameterObject) at Microsoft.VisualStudio.ProjectSystem.PackageReferences.NuGetRestoreService.NominateAsync(ProjectRestoreInfo restoreData, IReadOnlyCollection1 inputVersions, CancellationToken cancellationToken)
And tells me to contact the maintainers. Here is file: ProjectSystemServerFault_cf2ef281-b6f1-4bab-b0a8-20de4e38e766.failure.txt

Is that error in the VS Code logs?

@terle
Copy link
Author

terle commented Dec 8, 2024

@terle - were you able to progress with the improved instructions in #314?

Yes, your setup-instructions to use VS Code and DevContainers helped a lot :) I ran into another issue when building, logs spews out a lot of these:
StreamJsonRpc.RemoteInvocationException: Request nominateProject failed with message: Cannot read properties of undefined (reading 'size')
at StreamJsonRpc.JsonRpc.InvokeCoreAsync[TResult](RequestId id, String targetName, IReadOnlyList1 arguments, IReadOnlyList1 positionalArgumentDeclaredTypes, IReadOnlyDictionary2 namedArgumentDeclaredTypes, CancellationToken cancellationToken, Boolean isParameterObject) at Microsoft.VisualStudio.ProjectSystem.PackageReferences.NuGetRestoreService.NominateAsync(ProjectRestoreInfo restoreData, IReadOnlyCollection1 inputVersions, CancellationToken cancellationToken)
And tells me to contact the maintainers. Here is file: ProjectSystemServerFault_cf2ef281-b6f1-4bab-b0a8-20de4e38e766.failure.txt

Is that error in the VS Code logs?

Yes,
Image

@aaronpowell
Copy link
Member

Can you raise an issue on https://github.com/microsoft/vscode-dotnettools with the logs and the extension/vscode version.

@aaronpowell
Copy link
Member

I'm pretty stumped, I'll have to do some more investigation into what might be the problem. The log seems to suggest that it can't find the packages on nuget.org, or that it's not even trying to look at nuget.org.

I can see that it's aware of the nuget.config file and it's skipping dotnet-eng that is defined there for most packages, which it should do, but the nuget.config defines that the alternative source is nuget.org, which is then failing for you for some reason.

Doing some testing, the only way I can reproduce this is by disabling the nuget.org source in the nuget.config file that we have in the repo (ie - removing the addition of the source).

@Odonno - what do you get when you run dotnet nuget list source in the repo root? It should look like this:

PS> dotnet nuget list source
Registered Sources:
  1.  nuget [Enabled]
      https://api.nuget.org/v3/index.json
  2.  dotnet-eng [Enabled]
      https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json

@terle
Copy link
Author

terle commented Dec 8, 2024

Can you raise an issue on https://github.com/microsoft/vscode-dotnettools with the logs and the extension/vscode version.

I'd love to help, but honestly man, I don't even understand the issue, so I wouldn't know where to begin.

@aaronpowell
Copy link
Member

Me either! My guess is something crashed in the extension when it comes to project loading. They have a bug template on the repo that'd guide through providing info that team would need to debug further.

I'll setup a new machine with a fresh VS Code and see if I can repo when I have a chance.

@terle
Copy link
Author

terle commented Dec 8, 2024

Me either! My guess is something crashed in the extension when it comes to project loading. They have a bug template on the repo that'd guide through providing info that team would need to debug further.

I'll setup a new machine with a fresh VS Code and see if I can repo when I have a chance.

ok, I'll give it a go when I got time.

@Odonno
Copy link

Odonno commented Dec 8, 2024

I'm pretty stumped, I'll have to do some more investigation into what might be the problem. The log seems to suggest that it can't find the packages on nuget.org, or that it's not even trying to look at nuget.org.
I can see that it's aware of the nuget.config file and it's skipping dotnet-eng that is defined there for most packages, which it should do, but the nuget.config defines that the alternative source is nuget.org, which is then failing for you for some reason.

Doing some testing, the only way I can reproduce this is by disabling the nuget.org source in the nuget.config file that we have in the repo (ie - removing the addition of the source).

@Odonno - what do you get when you run dotnet nuget list source in the repo root? It should look like this:

PS> dotnet nuget list source
Registered Sources:
  1.  nuget [Enabled]
      https://api.nuget.org/v3/index.json
  2.  dotnet-eng [Enabled]
      https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json

Oh. I think you have pinpoint the problem. NuGet is disabled. I am not sure why... Let me see.

@Odonno
Copy link

Odonno commented Dec 8, 2024

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

@aaronpowell
Copy link
Member

I'm going to go ahead and close this issue now. I've also merge #314 so hopefully onboarding is smoother in the future.

@terle
Copy link
Author

terle commented Dec 12, 2024

But I still got an issue? Feels kinda weird that you would close this. I don’t mean to be a jerk, but I’m trying to contribute. I am unable to build and seeking help and now the you close the issue??
What would advise you me to do now?

@aaronpowell
Copy link
Member

Apologies, I lost track of who had outstanding issues.

Are you still having the problem with the C# extension? Can you confirm it's the latest version of the extension and the latest VS Code? Admittedly, I'm not sure there's something that we can resolve on our end as the error in the logs is coming out of the project system for the C# DevKit extension.

@aaronpowell aaronpowell reopened this Dec 18, 2024
@terle
Copy link
Author

terle commented Dec 22, 2024

No worries. I imagine it can be difficult to be maintainer some times :)

Yes, I still experience the issue, but I closed my eyes and ears and pressed forward.
I've been having numerous errors ever since, I'm trying to manage myself, but honestly it's really draining my energy here.
I feel like a play whack-a-mole with every type of error known to mankind, and I'm blind.
The setup and build process is complicated (with good reason) but it is lacking in documentation, making it REALLY hard for new comers like me. It's an uphill battle man.

Currently, I'm struggling with:

  • PublicAPI.(UN/)Shipped.txt. Syntax/building
  • Unit tests that won't execute (keeps running forever)
  • Extensions that block startup
  • Missing .mnvm file for some java-stuff

My current strategy is to ignore errors and push forward, but it's not a fun experience. If you don't mind, check out https://github.com/terle/aspire-communitytoolkit/tree/main, and tell me what I've missing in the publicApi-files. Thanks.

Happy holidays 🎄

@Alirexaa
Copy link
Member

Alirexaa commented Dec 22, 2024

@terle , Check https://github.com/CommunityToolkit/Aspire/blob/main/docs/public-api.md for Public Api files stuff.

@aaronpowell, Should we add a reference to the public-api in contribution guide?

@aaronpowell
Copy link
Member

@terle First off, let me say a big thank you for continuing to persevere in what is a frustrating experience for you and could very easily end up in the "this is too hard" basket and dissuade someone from contributing. Your continued feedback helps us make it a better experience for the next person who wants to contribute.

I've created issues #339 to decrease the impact of Java on building the codebase, and #340 on handling the public API files.

Do you know which unit tests are hanging? The most common reason I've seen tests hanging is when there is a wait condition on a resource that is never met, but this is only in the integration tests now the unit tests, so if you have an idea of which one(s) are the problem I can look more into them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

4 participants