Unresolved NuGet Dependency References
I have XUnit added as a dependency to my test project via NuGet. Despite this, my test project code seems to oscillate inexplicably between recognizing all of the dependency references and not.
This doesn't really make any sense to me as I can successfully build and run the test project, but when I reload it all of the references become unrecognized.
I have been using visual studio to set up projects/dependencies and working in VSCode, and even if I can build everything in VS just trying to scan for the test projects in VSC loses the dependency references.
20 Replies
these are all of the NuGet packages my project has installed
it's just XUnit that isn't working all the time
I have other projects in the solution that do not have the same issue
you are importing the namespace right?
just to make sure
it doesn't even recognize the namespace
literally every other build succeeds
have you tried deleting the .vs folder
and obj
and whatever other stuff it generates
then run dotnet restore then open vs
should I run restore on the solution directory? I have multiple csproj projects in the solution
this is the file structure with all of the csproj files
the test project only includes Xylem/test
the main project (Xylem) includes Xylem/data and Xylem/src
sure
I think Xylem and Xytest are using the same obj path for building
so building one clears the dependency files for the other
I probably need to separate the structure
why do you even set the path
what do you mean
I haven't made any manual changes to anything
in any case I have rearranged the projects so no two csproj share the same folder and everything seems fine
oh they were sharing a folder
yea
yeah don't do that
$structure
For C# versions older than 10, see
$StructureOld
oops not that one
anyway generally i have a
src
folder for the actual app and a tests
folderI had the main/test project separate
so I wanted to move the tests into the main project without adding the XUnit dependency to the main project
so my structure is like this now:
and the MainProject excludes the test directory
thats worse imo
and probably most peoples opinion
just have the tests directory under the root, completely seperate from source
I was thinking I needed the data directory which is at the same level as src
but I don't actually so that does make sense