Heinzi
Heinzi

Reputation: 172230

How can I make Visual Studio copy a specific file to the publish directory?

I am using the Publish feature of Visual Studio to create a ClickOnce setup file for my VSTO add-in.

I know that I can cause files to be deployed together with the application by setting their Build Action to Content. Let's say I have a file called readme.txt, whose Build Action is set to Content. This is what happens:

publish
+-- setup.exe
+-- MyAddIn.vsto
+-- ApplicationFiles
    +-- ...lots of files..
    +-- readme.txt.deploy     <--

Since the file contains information that I want the user to read before installing the application, this is what I want to happen:

publish
+-- setup.exe
+-- MyAddIn.vsto
+-- readme.txt                 <--
+-- ApplicationFiles
    +-- ...lots of files..

Is there an easy way to do that?

Upvotes: 3

Views: 1154

Answers (2)

Andrew Keeton
Andrew Keeton

Reputation: 23311

At the bottom of the project file:

<Target Name="AfterPublish">
    <Exec Command="xcopy.exe /Y &quot;$(TargetDir)readme.txt&quot; &quot;$(PublishUrl)&quot;" />
</Target>

Here's what I was working on in case this more general scenario is useful for others:

<PropertyGroup>
    <ReadmeFilesDir>README-files</ReadmeFilesDir>
</PropertyGroup>

<Target Name="AfterPublish">
    <Exec Command="xcopy.exe /Y &quot;$(TargetDir)README.html&quot; &quot;$(PublishUrl)&quot;" />
    <Exec Command="xcopy.exe /E /I /Y &quot;$(TargetDir)$(ReadmeFilesDir)&quot; &quot;$(PublishUrl)$(ReadmeFilesDir)&quot;" />
</Target>

I wonder if there's a badge for answering a six year-old question.

Upvotes: 4

Ido Tamir
Ido Tamir

Reputation: 198

Maybe you can use a post-build command to move the file to the location you want, then the wizard will package the folder as is.

Upvotes: -1

Related Questions