Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 762625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T16:25:24+00:00 2026-05-14T16:25:24+00:00

I have some content files that I would like to share between a number

  • 0

I have some content files that I would like to share between a number of projects in Visual Studio.

I have put these files in their own project, set the build action to “Content”, and the copy to output directory to “Copy if newer”. I would like all these files to be copied to the bin/debug directory of the projects that reference them.

I can get it to work by including a reference to the “contents” project in each of the projects that need the files, but that requires that a minimal assembly be generated (3K). I assume there is a way, using MSBuild, to make this all work without creating the empty assembly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T16:25:25+00:00Added an answer on May 14, 2026 at 4:25 pm

    Thanks to everone who took the time to make a suggestion about how to solve this problem.

    It turns out that if I want my compiled content files to be treated like content files (in that they get copied to the output directory of any other project that references my project), I need to create a target which runs before GetCopyToOutputDirectoryItems, and add the full path of the compiled content files to the AllItemsFullPathWithTargetPath ItemGroup. MSBuild calls GetCopyToOutputDirectoryItems for projects on which the current project depends, and uses the resulting file list to determine the files that are copied along with the assembly.dll. Here is the XML from my .csproj, just in case someone else has a similar problem.

    I have a custom task called “ZipDictionary”, and I accumulate all the files that I am going to compile in an ItemGroup called DictionaryCompile. My target, “FixGetCopyToOutputDirectoryItems” is executed before “GetCopyToOutputDirectoryItems”. I don’t do the actual compilation there, since this target can be called multiple times by referencing projects, and it would hurt performance. The target does some transforms to get the post-compilation file names, and then returns the full paths to all the files, since relative paths will not work when copy is called from the referencing project.

    <ItemGroup>
      <DictionaryCompile Include="Dictionaries\it-IT.dic">
        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      </DictionaryCompile>
    </ItemGroup>
    <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    <UsingTask TaskName="ZipDictionary" AssemblyFile="..\LogicTree.DictionaryCompiler\bin\Debug\LogicTree.DictionaryCompiler.dll"/>
    <Target Name="BeforeCompile">
      <Message Text="Files @(DictionaryCompile)" Importance="high" />
      <ZipDictionary DictionaryFiles="@(DictionaryCompile)" OutputDirectory="$(OutputPath)">
        <Output TaskParameter="OutputFiles" ItemName="DictionaryOutputFiles" />
      </ZipDictionary>
    </Target>
    <Target Name="FixGetCopyToOutputDirectoryItems" BeforeTargets="GetCopyToOutputDirectoryItems">
      <ItemGroup>
        <_DictionaryCompile Include="@(DictionaryCompile->'$(OutputPath)Dictionaries\%(FileName).ltdic')" />
      </ItemGroup>
      <AssignTargetPath Files="@(_DictionaryCompile)" RootFolder="$(MSBuildProjectDirectory)\$(OutputPath)">
        <Output TaskParameter="AssignedFiles" ItemName="_DictionaryCompileWithTargetPath" />
      </AssignTargetPath>
      <ItemGroup>
        <AllItemsFullPathWithTargetPath Include="@(_DictionaryCompileWithTargetPath->'%(FullPath)')" Condition="'%(_DictionaryCompileWithTargetPath.CopyToOutputDirectory)'=='Always' or '%(_DictionaryCompileWithTargetPath.CopyToOutputDirectory)'=='PreserveNewest'" />
        <_SourceItemsToCopyToOutputDirectoryAlways Include="@(_DictionaryCompileWithTargetPath->'%(FullPath)')" Condition="'%(_DictionaryCompileWithTargetPath.CopyToOutputDirectory)'=='Always'" />
        <_SourceItemsToCopyToOutputDirectory Include="@(_DictionaryCompileWithTargetPath->'%(FullPath)')" Condition="'%(_DictionaryCompileWithTargetPath.CopyToOutputDirectory)'=='PreserveNewest'" />
      </ItemGroup>
    </Target>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some files in a folder on the harddrive, like C:\ExtraContent\ that has
I have a class library project which contains some content files configured with the
I have some content that I want to appear on multiple pages of my
I have some content that I am loading using jquery ajax. The content has
I have some content like this: author = Marjan Mernik and Viljem Zumer, title
I have a quick question that I'm sure some of you would have an
I'm new in programming. In VB2005, I have some object files, like a.vb, b.vb,
I have a client that would like to use SkyDrive as a cloud storage
I have some files that I need to include in several pages so, I
I have several domains that I would like to have wildcard subdomains enabled for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.