简体   繁体   中英

Visual Studio updates binaries of project which is not supposed to be built

I'm trying to prevent Visual Studio from overriding my binary folder of a project which is not supposed to be used during a build. Imaging the following solution structure:

App1 -> LibB -> LibA

Every time I'm trying to build the LibB project (build/rebuild) it replaces LibA.dll in my App1 binary folder. The real issue is in different version of LibA.dll used by App1 and LibB . Imaging I have another App2 project:

App1 -> LibB (v2) -> LibA (v2) App2 -> LibB (v2) -> LibA (v2) LibB (v2) -> LibA (v1)

And now every time I'm building the App1 project it ruins the binary folder of my App2 project because when the LibB project is build it moves LibA.dll (v1) to my App2 binary folder which is not expected behavior.

ps#1: I cannot update LibB (v2) to use LibA (v2) just because it's a simplified issue description and there are plenty of dependencies like I described above. Let's say it's going to be my long term solution.

ps#2: If you try to build LibB project it WILL update App1 and App2 binary folders with LibA.dll (v1) and ruin both app projects.

ps#3: I recreated a test solution with similar dependencies model and it works just fine so it's an issue of the existing solution I'm trying to fix.

How can I prevent Visual Studio from updating a parent project when a child project is being built?

When using project references in Visual Studio it is the design of Visual Studio to keep them in sync, this is by design. If you have shared libs across multiple applications you should have them in different solutions and manage the dependencies across solutions with a package management product like nuget.

How can I prevent Visual Studio from updating a parent project when a child project is being built?

every time I'm building the App1 project it ruins the binary folder of my App2 project because when the LibB project is build it moves LibA.dll (v1) to my App2 binary folder which is not expected behavior.

I believe it is by-design, never the less one way to stop App1 ruining the Bin Folder of your App2 project is to make copies of the Project Files (.csproj's) and change the Output Bin folder in the Project Properties.

Then have a few different Solution Files (.sln's) to open the different version reference configured projects.

Make sure you have your dependencies across projects sorted and your Configuration Manager settings are proper for a solution-level build

You can always build a specific project individually from within the solution as well

不要使用项目引用 ,而是从某些外部文件夹(如C:\\ DeployedBinaries)链接到库的已编译二进制文件,并在需要时手动将所需二进制文件复制到C:\\ DeployedBinaries

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM