MSBuild doesn't copy references (DLL files) if using project dependencies in solution

前端 未结 19 1333
Happy的楠姐
Happy的楠姐 2020-11-22 07:24

I have four projects in my Visual Studio solution (everyone targeting .NET 3.5) - for my problem only these two are important:

  1. MyBaseProject &
相关标签:
19条回答
  • 2020-11-22 07:58

    Take a look at:

    This MSBuild forum thread I started

    You will find my temporary solution / workaround there!

    (MyBaseProject needs some code that is referencing some classes (whatever) from the elmah.dll for elmah.dll being copied to MyWebProject1's bin!)

    0 讨论(0)
  • 2020-11-22 07:58

    Make sure that both projects are in the same .net version also check copy local property but this should be true as default

    0 讨论(0)
  • 2020-11-22 08:01

    I had the same problem and the dll was a dynamically loaded reference. To solve the problem I have added an "using" with the namespace of the dll. Now the dll is copied in the output folder.

    0 讨论(0)
  • 2020-11-22 08:02

    I just deal with it like this. Go to the properties of your reference and do this:

    Set "Copy local = false"
    Save
    Set "Copy local = true"
    Save
    

    and that's it.

    Visual Studio 2010 doesn't initially put: <private>True</private> in the reference tag and setting "copy local" to false causes it to create the tag. Afterwards it will set it to true and false accordingly.

    0 讨论(0)
  • 2020-11-22 08:02

    Including all referenced DLL files from your projectreferences in the Website project is not always a good idea, especially when you're using dependency injection: your web project just want to add a reference to the interface DLL file/project, not any concrete implementation DLL file.

    Because if you add a reference directly to an implementation DLL file/project, you can't prevent your developer from calling a "new" on concrete classes of the implementation DLL file/project instead of via the interface. It's also you've stated a "hardcode" in your website to use the implementation.

    0 讨论(0)
  • 2020-11-22 08:03

    Referencing assemblies that are not used during build is not the correct practice. You should augment your build file so it will copy the additional files. Either by using a post build event or by updating the property group.

    Some examples can be found in other post

    • MSBuild to copy dynamically generated files as part of project dependency
    • VS2010 How to include files in project, to copy them to build output directory automatically during build or publish
    0 讨论(0)
提交回复
热议问题