Is there a way to get a dll updated in a post-build-event copied into the /obj folder?
Modifying the dll (to embed some generated files) in the post-build works fine, but after a ReBuild, the /obj folder always contains the 'old' dll (before the post-build event is triggered).
This causes problems when building other projects (which seem to use the 'wrong' dll from /obj folder in some cases).
Can this be done automatically, or is it only possibly via another post-build-command to copy the dll by hand?
Can this be done automatically, or is it only possibly via another post-build-command to copy the dll by hand?
The answer is yes, you can add a xcopy command after Modifying the dll in post-build-command:
echo Execute Modifying dll Event.
xcopy.exe "$(ProjectDir)TheModifyiedFolder\Modifying.dll" "$(ProjectDir)obj" /y /s
Related
I have a console application and when I run it, an exe file is generated in Bin/Debug folder.
How can I change the path of exe generated to parent folder where src resides?
I created a c# console .Net Framework 4.8 project, there are two ways to achieve your needs.
The first way you can directly change the way the exe is generated in the properties, and the second way you can use the post-build method to copy the exe to src.
The first:
Modify in project->properties->build->output, for example, modify to ..
The Debug folder will be generated to the upper layer.
The second: copy only the exe.
xcopy /y /e "$(TargetPath)" "$(SolutionDir)"
Click on edit to view macros, or refer to documentation.
If you want to use it in .net.
xcopy /y /e "$(Targetdir)*.exe" "$(SolutionDir)"
I have an exe being dropped into my bin directory however sometimes this exe will be dropped into debug or release. Is there any way to - from a post-build event - say "hey, wherever we built this thing, copy it into the wwwroot folder"?
I see the following: http://www.benramey.com/2010/06/29/visual-studio-post-build-event-to-copy-dlls/
Where this code is used:
cd $(ProjectDir)
copy /y bin\debug\*.dll C:\inetpub\wwwroot\wss\VirtualDirectories\{YOUR SHAREPOINT SITE DIRECTORY}\bin
However I want to not specify debug or release or netcoreapp2.0 or netcoreapp:
How can this be achieved?
Use the provided macros. You already used $(ProjectDir).
$(TargetPath) will contain the complete path to the executable.
$(OutDir) will contain the output directory (relative).
Met a problem. VS2013 doesnt allow to merge files into same exe which created after build.
"$(SolutionDir)ILMerge\ILMerge.exe" "$(TargetPath)" "$(SolutionDir)..\Lib\Soft.dll" /out:"$(TargetPath)"
My idea was to merge built exe with 1 dll (uses in references) and to have the same exe filename.
I can do this without any problem apart of VisualStudio.
But i prefer to do merge exactly in post-build event, and do not change the exe filename.
Is there some workaround ?
PS. I dont want to have a dll in resources, because its used a lot, and its easy to have as usual in references
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.
i am using some libraries and i added a reference to that library dll and i set the "Copy Local" to true.
but i want to change the location of the dll to be a subfolder in the exe folder and not with the exe.
how is this possible?
thanks
Update:
i used the following Post-build event [as Jon Skeet recommended]
move /y $(TargetDir)\System.Data.SqlServerCe.dll $(TargetDir)\Lib\SqlSrvCe\System.Data.SqlServerCe.dll
You'll need a .config file for your .exe so that the probing path is changed. A subdirectory is no problem, just use the <probing> element, its privatePath attribute is a relative folder name.
Beware however that you'll get little help from the IDE to put the DLL in that spot. You'll need a post build event that creates the folder if necessary and xcopy's the DLL there. Something like this:
if not exist "$(TargetDir)mumble" mkdir "$(TargetDir)mumble"
xcopy /d /y "$(TargetDir)something.dll" "$(TargetDir)mumble"
I don't know whether it's feasible within "normal" build rules, but you could add post-build steps which basically moved the files. It would be ugly, but it should work.
Do you need it as a reference? Or is the reference only to copy the dll to the desired location?
If you do not need the reference, try adding it to the project and setting it to always copy.
Add the dll to a folder in the project and set to Copy to Output Directory http://web11.twitpic.com/img/146848312-ecfdeadf5b322fe755c7a764d6e6dbf0.4c69c2f0-full.png