VS2010 How to include files in project, to copy th

2019-01-04 02:23发布

Task is to form Visual Studio 2010 project so, that during any build or publish some foo.exe utility should be copied to output (bin) directory.

Early I have made PostBuildEvent task in .csproj (MSBuild-file):

<PropertyGroup>
  <PostBuildEvent>
    Copy "$(SolutionDir)Tools\foo.exe" "$(ProjectDir)$(OutDir)foo.exe"
  </PostBuildEvent>
</PropertyGroup>

But this is not universal. During publishing (Visual Studio 2010) foo.exe appears in bin directory, but is not copied to output publish directory. Maybe I do everything completely wrong and there is standard mechanism to include files in projects to be later, during build or publish, copied to bin?

7条回答
干净又极端
2楼-- · 2019-01-04 03:28

Just so my fellow neuronically impaired comrades might chance upon it here, I had assumed that, for web projects, if the linked file was an external .config file that the "output directory" would be the same directory that web.config lives in, i.e. your web project's root. In retrospect, it is entirely unsurprising that it copies the linked file into the root/bin folder.

So, if it's an appSettings include file, your web.config's open tag would be

<appSettings file=".\bin\includedAppSettingsFile.config">

Duh.

查看更多
登录 后发表回答