简体   繁体   中英

Copy dll files to .exe directory in ClickOnce deployment

My .NET project depends on a bunch of native dll libraries that should be copied into the same directory as .exe file. Dll files are added to main project to "ExternalDependencies" folder and are copied to output folder upon custom post-build action.

When I publish my app with ClickOnce utility all dlls are placed into ExternalDependencies/ relative path, not in the same directory as exe.

I don't want to put the libraries into root of the project, but I have to find a way to change relative path during installation. I found no way of doing this, except for manual manifest generation: https://msdn.microsoft.com/en-us/library/xc3tc5xx.aspx

Maybe I am missing something? Is there an easier way to do this?

Ok, figured it out. This blog post describes the hidden possibilities of project files which allow to do what I want: http://blogs.msdn.com/b/mwade/archive/2008/06/29/how-to-publish-files-which-are-not-in-the-project.aspx

Basically you should add an item to you project file for each file you will be deploying if you want a custom path for it:

<ItemGroup>
<PublishFile Include="ExternalDependencies\DSAPI.dll">
  <Visible>False</Visible>
  <Group>
  </Group>
  <TargetPath>DSAPI.dll</TargetPath>
  <PublishState>Include</PublishState>
  <IncludeHash>True</IncludeHash>
  <FileType>File</FileType>
</PublishFile>

TargetPath property is what I was looking for. It's a shame you cannot change it from VS UI!

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