My project does not add reference to another in the same solution.
I created a project for a website and and abstracted all the parts of the program into .Net Class Libraries (My models in a different class library, Interfaces in a different class library, business logic in a different class library). I referenced all the projects correctly and I also tried creating something I call EntityRepository which I initially kept the DbContext inside. But due to the reason that I wanted to use Microsofts' implementation of Identity and then scaffold the logic out, I could not find the DbContext from the other project which is required when scaffolding so I had to exclude that project out of the solution. Normally when you create a project and select Single user authentication, .Net core adds an initial DbContext into the project. So when scaffolding the implementation of AspNetCore Identity into my project, i have to choose the DbContext. Because of that, my business logic has broken into two sides. The other logic is inside another project in the same solution, the Identity and authentication is inside the startup project which is the web application. When I tried calling the services which implement the business logic from the other project into the web project, it could not add reference to the services project. I now added reference manually. After that I now saw an error written
Detail Error:
Severity Code Description Project File Line Suppression State
Error NU1108 Cycle detected.
CBTSoftware.Web.Host -> CBTSoftware.Services -> CBTSoftware.Web.Host. CBTSoftware.Web.Host C:\Users\Tavershima\source\repos\CBTSoftware\CBTSoftware.Web.Host\CBTSoftware.Web.Host.csproj 1```
How can I resolve this?
Fist I want to show gratitude to those who answered above because they put on the right track to solving this issue. In my case the issue was caused by untrack files causing NU1108 and was resolved by running git clean -fxd
*git clean documentation
I know that this is old but I'd like to add here as well.
I had the same situation as Sebastian Widz answer but what really worked for me was opening the Properties of the problematic project.
This reloaded the project files/dependencies and fixed the "Cycle Detected" issue.
In my case the problem had nothing to do with actual dependencies.
One day I opened a solution (which was fine the day before) and could not compile it. NU1108 Cycle detected error was reported in error log for several projects.
Solution:
Examine all projects in the solution, check the solution content.
If for some projects you see wrong content like if the project had files attached from a different project, expand its nodes and wait a bit, VS should refresh the nodes after a while
You may also try to Clean Solution and Reload each project.
Consider making a project to contain your EntityRepository, like CBTSoftware.Data, and adding a reference to it from your services project:
CBTSoftware.Services -> CBTSoftware.Data
Then, you can continue referencing your services project from your web project:
CBTSoftware.Web.Host -> CBTSoftware.Services
You'll still be able to configure your EntityRepository in your Startup.cs file because it will know about your CBTSoftware.Data project transitively. Just make sure to remove the reference to your web project from your services project, since this is creating a cycle.
I have solved the problem by deleting the DbContext which i created in the Web Project and using the one which I created in another project which is a .Net Library then I added this line of code in my StartUp.cs file
services.AddDbContext<CBTDbContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
By adding it, I was able to find the DbContext in the Web Project.
Then another problem has arisen when I'm trying to add migrations. Which I would open in another post
I also had this issue
In my case, I was using multiple projects in one solution. And in one of those projects, it's Dependencies was showing warning signs, within these Dependensies, there was a folder with included projects also each showing a warning sign.
I could solve it by right-clicking on the Dependencies, click on 'Add Project Reference' and then unselect all projects related to it/showing the warning signs.
After rebuilding, the cycle problem was gone.
Related
So, I'm having trouble adding a git project to my net Core solution, and after spending hours trying to figure this out and being uncapable of finding a solution online, I decided to ask here.
I have a forked github repo (link) in which I modified some files to suit my needs, but I simply can't seem to get it to work with my current project.
The problem I'm having is that normally, when I want a package for a .NET project, I usually simply go to nuget and fetch the necessary dependencies. This is usually very simple and straight forward. But now that I have these modified files, I'm unsure on how to proceed.
I have tried adding it as a submodule, but after I built the project, I got an exception saying that the dll could not be found.
Then I've tried adding the dll itself as a reference, but the ImGui.dll depends on a C dll which couldn't be found then (nor added to the project).
Finally, I've tried adding the csproj as a project of my solution, but that didn't work either
Do you know what am I doing wrong here? Am I missing a key piece or is it just something obvious I'm not seeing? It can't be this hard to get it to work
From the look of it, that repository produces a DLL (output type Class Library). So modify it to your liking, and use the sample program build (ImGui.NET.SampleProgram) to test your changes. Once you're happy, build the DLL project (ImGui.NET) and use the resulting DLL as a Reference in your own app.
In Visual Studio:
Solution Explorer>YourApp>References>Right Click>Add Reference...>Locate your DLL
This means you should also keep track of your modifications to the ImGui.NET project itself, since you may/will be required to maintain this in the future.
Hope this gets you started -- update your question with more specific issues once you're underway.
Edit:
Like #CoolBots mentions, I probably misread your question. Seems like the build depends on cimgui.dll, which you can hotlink from the ImGui repo along with your custom DLL. In fact, the demo app is using cimgui.dll, cimgui.dylib and cimgui.so. Regardless of linking method, you want the files to copy into your build folder. I don't believe subfolder /bin is necessary.
You can find all the cimgui dependencies for various operating systems in the ~/ImGui.NET/deps/cimgui folder.
The demo also utilizes NuGet packages Velrid and Velrid.StartupUtilities.
Depending on your own codebase, you may or may not require these NuGet packages along with the aforementioned class library.
I had a solution that contained two projects, one for the web layer that also contained the models, and another for a Windows forms project that did some other "stuff". The forms project referenced the web project, and all was fine up until I needed to reference something from the web project in the forms project, which I could not do for circular reference reasons.
So I created a new solution, put the data layer in one project and the web layer in another, so later on I could add the third project, and put in the references I need. Now when I run the web project, I get the following error;
So I understand that the web project is struggling to find my namespace from the data project, but I have referenced it, so I don't know what more to do.
***EDIT
This comes as no shock, but it's the view that's the issue. If I edit my Index.cshtml, it recognises the referenced project. I tried adding;
#using LottoData.Models
and intellisense completed as I typed. However, when I run it now, I get;
Help!
This was my bad. I forgot to change the output type for the data project to "Class Library", it was still set to "Console Program". Changed that, removed and re-added the reference, cleaned and rebuilt and it works fine now. Thanks #David and #Armand for your input.
I have a VS 2017 solution with 2 .Net Core 1.1 projects, 1 is just a class library containing all of my domain models and the other is the actual MVC web application containing the contexts (the ApplicationDbContext & one I created) & all of the EFCore assemblies. I'm trying to enable & use migration on the context I created but having trouble being that the context is in the WebUI project and the models are in the class project. Upon 1st execution of Add-Migration command, I got this error about my target project didn't match my migrations assembly, so I figured out how to get around that by changing the migration assembly in Startup.cs. Add-Migration ended up working but the migration file was created in the class project where the EFCore assemblies are not referenced, thus giving an error on the migration file. I thought maybe I'd try and trick it by moving the file to my WebUI project to update the database, but then figured that may not work & there has to be an easier way of doing this. Does anyone know how to setup code first migrations for EFCore to keep track of modifications and update the database when my domain models are in another project? Any help would be greatly appreciated. Hopefully this isn't too vague. If more info is needed, I'll be all too happy to post. Thanks.
I may not be understanding the question correctly, but have you tried referencing your domain project in your webUI?
I've a solution containing 239 projects. I've currently the following issue:
When I do a "rebuild all" on the solution, after having done a full clean(delete of the output directory):
17>------ Rebuild All started: Project: AAA, Configuration: Debug x86 ------
18>------ Rebuild All started: Project: BBB, Configuration: Debug x86 ------
18>CSC : error CS0006: Metadata file 'E:\Dev\Trunk\Debug\x86\AAA.dll' could not be found
17> XmsCommon -> E:\Dev\Trunk\Debug\x86\AAA.dll
I understand the following:
Visual studio is multithreading the compilation(in my case, 4 assembly at a time)
I've no explicit "Project Dependency" specify(Right click on solution -> Project Dependencies)
What I don't understand
In this example AAA is a referenced project of BBB, for me, it's an implicit dependency, how would it be possible to correctly build BBB without being sure that AAA has been built correctly?
How should we manage this for a solution that makes 239 projects? It's hard enough to ensure that we don't make any reference to a wrong project, so if we always have to ensure the build orders, it becomes complicated.
A single note: I don't know if this is due to a recent change(of a project/visual studio/...), because it makes 2 years I work on this solution, and it's the first time that I came accorss this issue again and again.
So the question:
Is there a way to handle this without having to indicate each Project Dependency on the solution?
If not, how should we do this?
EDIT
After the comment, here is some additionals infos:
There is no compilation errors in AAA or BBB except it can't find the reference
We references projects and not dll(checked in one specific case where I was having the error.
In BBB.csproj, I've the following reference:
<ProjectReference Include="..\..\..\..\SomeOtherFolder\AAA\AAA.csproj">
<Project>{6241076B-05B3-4D5D-AFA9-46D41E1CEC3A}</Project>
<Name>AAA</Name>
<Private>False</Private>
</ProjectReference>
EDIT 2
I don't know if this is directly related, but when checking the Project Dependencies, I found that BBB is depending on CCC(but nothing is indicated for AAA. I'm wondering if there is a dependency specify, it basically ignore all the informations coming from the references? If I try to remove the CCC dependency, I got a message:
This dependency was added by the project system and cannot be removed
EDIT 3
I made an interessting discovery: In fact the error I've in the EDIT 2 is because this dependency has been added when creating the reference between the two projects.
For an unknown reason, it seems this dependency has not been created for one reference here. If I remove the project reference, then add the reference again to the same project, I now have this dependency(which I cannot delete).
I can't find where this "dependency is stored.
Any idea on how to "fix" this solution wide?
From your post you said that
"I've no explicit "Project Dependency" specify(Right click on solution -> Project Dependencies)" This implies that all of your references are to the compiled DLLs, and not to the projects.
I have seen this approach many times done by teams with large solutions (you have 239 projects) due to the slowness of VS to load that many project references.
The workarounds that I have seen used are:
Multiple Solutions for each sub-area of the primary solution, such as Entities, DAL, Logic, Service, etc.
Checking in DLLs (not recommended, but I have seen it) into Source to be used for faster builds. Once you change a code area you are responsible for replacing the DLL.
Configuring the Project Dependencies settings so that builds are done in proper order.
Dealing with the performance of the Project References (slow, but ensures build order
A single solution with 239 projects seems to go against the tenet of compartmentalizing your development into smaller modules, but that isn't always your decision...
After some investigation, I found the issue:
In fact Visual Studio should automatically add those dependency between the projects when referring one into a project. I can see that very easily by just adding a project reference. In addition, it seems that those "dependencies" cannot be removed(see my edit 2).
So the question I asked is how can I have some projects referenced and no dependency for some projects?
I checked that my references(at least some case I saw it wasn't working) and they were project reference and not dll.
Some of my colleague, with the exact same code(Get latest version of code without changes) were not having this issue, and were having the dependency displayed in Visual studio.
So I ended by removing the *.sdf file near my solution file(after having closed visual studio). I reopened and tadaa, all the dependencies have been recomputed by visual studio. Now we I rebuild, everything is a success directly.
I'm not sure of why it happens, I had some time to kill visual studio, maybe something was corrupted then.
I have seen this issue in a smaller, but highly inter-dependent solution. We solved this issue by reducing the Maximum number of parallel project builds lower until it predictably succeeds. Tools --> Options --> Projects and Solutions --> Build and Run.
I know this is not a solution, but you could turn your compile dependencies into runtime dependencies is you use Dependency Injection technologies, like MEF or Unity.
In this case, your projects have limited dependencies (Interfaces, Containers).
But I have to say, these technologies carry some side effects - like 'pseudo random' initialization and so on...
I'm working on an MVC 3 project. I was told to get all the models and viewmodels out of the projects and put them in a class library so that they can be referenced from different types of projects. However, now that I've transferred all the viewmodels and models from the web project to a class library, and removed all the references to the web project, I cannot set reference to the class library from my web project with the reason stated in the question title. WHy is this happening? In my class library I'm not referencing the main project anywhere!!! Any suggestions? Thanks a lot!!
Experienced this earlier. Check the project that you are going to add if it has the reference to the project you are adding in it.
Example: Project A with reference to Project B. Then in Project B, you're adding Project A as reference.
well this usually happens for a reason, and this is that there is a cirrular reference,maybe not a direct one but an indirect one (through third project, how many projects do you have in your solution?).
In your library project remove all other projects references from solution, and try it again.
good luck
almir