VS, Web site project, pre-build action causes resource dll copy fail RRS feed

  • Question

  • User1562156107 posted


    I've been tinkering with adding more pre-build events on various projects to cut down the number of manual steps it takes a developer to get set up, but I'm running into something weird and can't find any threads directly on topic.

    So, we have a web site project in VS 2010.  I can't put pre-build events on that, but I can put them on the code libraries that the application ultimately ends up using.  One of these assemblies is a big resource dll.

    With no pre-build action, VS 

    1) creates the /Bin directory under the web site project

    2) copies the various localized resource dlls to lang-specific subdirectories under /Bin - e.g. /Bin/da/MyResources.resources.dll

    But when I add a pre-build action on some other project that will create the /bin directory under the web site project and seeds it with a referenced assembly (Brettle.Web.NeatUpload), suddenly the resource copies fail with

    Cannot copy assembly 'MyResources.resources.dll' to file 'C:\source\p4_ws\MyApp\main\src\application\bin\da\MyResources.resources.dll'. Unable to add 'C:\source\p4_ws\MyApp\main\src\MyResources\bin\Debug\da\MyResources.resources.dll' to the Web site. Unable to add file 'bin\da\MyResources.resources.dll'. The system cannot find the path specified.

    I'm inferring that VS has some binary logic that says "If there's no bin directory, set it up + set up the resources dir tree : otherwise take it as given"  So if I create the bin directory, VS won't go ahead and set up the subdirs for localization.

    But I can't find any docs on that.  I've found lots of threads about copies failing because assemblies already in use, but nothing at all about how the localized resources get copied over to a website during build.

    Can anyone shed some light on this?



    Monday, May 12, 2014 12:00 PM

All replies

  • User-166373564 posted

    Hi Mark,

    According to your description above, you want to copy dll file to bin folder.

    If you make the reference, VS copies them into the /Bin folder.

    Here are some discussions for this topic.

    Copy Local dll: http://forums.asp.net/t/1684016.aspx 

    Copy dll file to bin folder or add reference: http://forums.asp.net/t/1385025.aspx 

    If you have any concern, please let me know.



    Tuesday, May 13, 2014 9:55 PM
  • User1562156107 posted

    Thank you for replying, but those threads simply cover the ground  before the problems I ran into.  I've tried all that, and there are still problems no matter which way I go.

    The problem is trying to get the right files copied around to a web site project that incorporates 3rd party tools + our own assemblies.  The problem 3rd party assembly is one that's only referenced by the .aspx code-behinds of the web site.

    In DEBUG mode, if I have a pre-build event create the Bin directory for the web site and copy in the dll, then the appropriate resource files don't get copied in - this is what the original post is about.

    I added a reference to the 3rd party component to one of our assembly projects; then things got copied correctly for the DEBUG build, but apparently the RELEASE build is smart enough to detect that our assembly doesn't really use the 3rd party component and so doesn't copy it.  Oddly, having a pre-build event create the web site Bin directory for RELEASE mode does copy the resource files properly; only DEBUG mode apparently doesn't.

    I thought of adding a reference to the website project in its own way (3rdpartyassembly.dll.refresh in an already-existing Bin directory) but

    a) I didn't want to write something to pluck that out of the build before installer packaging

    b) There would have been a lot of tweaking to our build scripts since bin is assumed not to pre-exist.

    I was more looking to understand the rules under which VS operated such that pre-creating the bin directory breaks resource file copies.  I just don't understand why it does that.

    Wednesday, May 14, 2014 8:26 AM