-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Fix various "Type or namespace not found" errors #20736
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
Conversation
2dc08f4
to
1a78f83
Compare
It's likely working better than before because |
That said, something must be changing or ref/Microsoft.AspNetCore.Antiforgery/ wouldn't need to be regenerated. This is probably because ReferenceAssembly.targets copies over |
Yeah, that's why. Re-genning strips out the PackageReferences from the ref project files. Will look into changing that now. |
Even more motivation to get a better fix than this - the re-gen'd ref projects have hard-coded PackageReference versions, which isn't ideal |
This is getting unwieldy/ugly with generated PackageRefs - some projects declare additional metadata on PackageRefs (e.g. |
691f507
to
1a78f83
Compare
This reverts commit 8218d6e.
- change is no longer needed with other fixes in this PR This reverts commit 8218d6e.
* Add manual packageReferences where needed * Add more explicit packageRefs * Fix typo * undo changes to blazor.server.js * Fix typo * Don't gen ref assemblies in CodeCheck
* Improve build reliability - ensure `ResolveCustomReferences` target executes before packages are used - `ResolveAssemblyReferences` and `ResolveAssemblyReferencesDesignTime` targets run too late - e.g. failed builds of Microsoft.AspNetCore.WebUtilities or Microsoft.AspNetCore.Hosting when building from root - add `GetReferenceProjectTargetPathMetadata` for ease of use as well as reliability - avoids extra work to get existing metadata (ref/ projects execute no tasks in this target) nit: rename `@(ReferenceProjectMetadata)` -> `@(ReferenceProjectTargetPathMetadata)` * Ensure `GetTargetPathMetadata` target runs with `$(TargetFramework)` set - ref/ projects all multi-target and otherwise no-op this target * Revert "Fix various "Type or namespace not found" errors (#20736)" - change is no longer needed with other fixes in this PR This reverts commit 8218d6e.
Fixes #20687
So, this works for me locally, but I'm not 100% sure why.
Here's my understanding of what's happening: For non-packable projects that are in the shared framework, when they are at the end of a chain of projectReferences from a (test?) project, their References which SHOULD get converted to PackageReferences by our build system, don't wind up getting passed as references to the compiler. Note that the same projects build fine when they are being built directly during build.cmd.
This only repros so far on machines running VS16.5.0 or VS16.5.1, which made me think it was related to #19133, since VS16.5.0 and 16.5.1 both have the 3.1.200 SDK, which has the 3.1.2 runtime, which has the bug - but that may be a red herring, as the symptoms don't actually line up (the 3.1.2 bug affected only projects with indirect references to certain CoreFx types - the current bug affects every packageReference in the affected projects). Below are examples of projects that had the failure:
IIS.NewHandler.FunctionalTests
referencesInProcessWebSite
referencesMicrosoft.AspNetCore.ResponseCompression
ReferencesMicrosoft.AspNetCore.WebUtilities
, which fails to build. The binlog tells me nothing about the PackageReferences here, but confirms thatSystem.IO.Pipelines.dll
doesn't get passed as a reference to the compilerIIS.NewHandler.FunctionalTests
referencesInProcessWebSite
referencesMicrosoft.AspNetCore.Hosting
referencesMicrosoft.AspNetCore.Http.Extensions
, which fails to build. Here, the binlog tells me thatMicrosoft.Extensions.FileProviders.Abstractions
version3.1.4
was resolved as a PackageReference, but the .dll wasn't passed to the compiler.I haven't been able to repro this locally from the command line with either
dotnet build
ordotnet msbuild
- only withbuild.cmd
from the root.So, the solution I have here is to just manually convert all of the affected
References
toPackageReferences
. There are still some warnings that I'm investigating, and I'm still in process of confirming all of the references & assemblyVersions look good in ILSpy, but so far it looks to be working. We definitely need to figure out exactly what caused this though, and revert this change in favor of a better one once we do - but this should at least unblock 3.1.4 if we can't solve that by Tuesday. This shouldn't get merged into master.Some more notes: