I need to use external DLL not referenced in my main project. I've made some tests and it's working but now, I need to do it automatically.
So, in my "Post Build" event of my main web project, I put this :
Call c:\mybat.bat $(SolutionDir) $(TargetName) $(Configuration)
And in c:\mybat.bat, I've this :
set solution=%~1
set target=%~2
set configuration=%~3
set appli=Project1
rem : MSBuild...
cd "%solution%%appli%" && "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MsBuild.exe" "%solution%%appli%\%appli%.csproj" /p:Configuration=%configuration% /p:Platform="AnyCPU"
rem copy DLL generate by build
xcopy /Y /R "%solution%%appli%\bin\%appli%.dll" "%solution%%target%\bin\%appli%.dll*"
rem copy views...
xcopy /Y /R /S "%solution%%appli%\Views\*.*" "%solution%%target%\Views\"
And it's did the trick.
But, when I publish my website, the DLL 'Project1.dll' is not in my 'website\bin' folder. Only in my Bin project solution.
How can I add my *.dll and my view folder in the publish files ?
You have to include those files into your project, as publish copies only files which the msbuild process is aware of (i.e. which have been part of the project itself).
Another option might be to have the msbuild target file updated (by including custom/enhaned targets in your project file).
https://stackoverflow.com/a/1403360/2298807 contains a list of articles which might be used as a starting point for this.