We have content (files/folders) created outside of VS2010. Using the project's "BeforeBuild", I'm able to import the files from our temp directory to our project's same directory structure. Once imported, how do we tell VS2010 IDE recognize Build Action as "Content"? In VS2010 IDE, the macro "Include in Project" does this for you. Does it have anything to do with specifying a file's MetaData? Here is what I have so far...
<Target Name="BeforeBuild" Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " DependsOnTargets="ImportProperties;CustomImportsTarget" />
<Target Name="ImportProperties">
<PropertyGroup>
<ImportSrcPath>$(temp)\$(MSBuildProjectName)\Imports</ImportSrcPath>
<!-- File to save project references to -->
<ImportLogFile>$(ImportSrcPath)\ImportResults.txt</ImportLogFile>
</PropertyGroup>
</Target>
<Target Name="ImportLogger">
<Delete Files="$(ImportLogFile)" />
<WriteLinesToFile File="$(ImportLogFile)" Lines="Import Results%09============" />
</Target>
<Target Name="CustomImportsTarget" Condition="Exists('$(ImportSrcPath)')" DependsOnTargets="ImportLogger">
<!--
==============================================================
Allows for dynamically created content (files/folders) to be imported from our temp directory to our project's same
directory structure as "Compile Include content"
i.e. move %temp%\scripts\1.1.0\sample.js to <project>\scripts\1.1.0\sample.js
==============================================================
-->
<Message Text="==============================================================%0aCustomImportsTarget Begin%0a==============================================================" />
<!-- Create an Item list that contains the files to import. $(ImportSrcPath) is the property that contains the location where
import source files are placed. -->
<CreateItem Include="$(ImportSrcPath)\**\*" Exclude="$(ImportLogFile)">
<Output TaskParameter="Include" ItemName="Files2Import" />
</CreateItem>
<!-- For testing purposes, Copy the files into our project. TODO:Should be a Move operation so project file modified dates are not constantly changing. -->
<Copy SkipUnchangedFiles="false" SourceFiles="@(Files2Import)" DestinationFolder="$(MSBuildProjectDirectory)\%(Files2Import.RecursiveDir)">
<Output TaskParameter="CopiedFiles" ItemName="Changed" />
</Copy>
<!-- Imported files are now located in our project folders,
How do we assign properties to the files in @(Changed) so VS2010 IDE recognizes Build Action as "Content"???
In VS2010 IDE, the macro "Include in Project" does this for you. Does it have anything to do with specifying a file's MetaData???
-->
<!-- Now send these values to the logger -->
<Message Text="Changed:@(Changed->'%(Filename)%(Extension)')" Importance="high" />
<Message Text="Script:@(Files2Import->'%(Filename)%(Extension)')" Importance="high" />
<!--<Message Text="MSBuildProjectDirectory:$(MSBuildProjectDirectory)" Importance="high" />-->
<Message Text="==============================================================%0aCustomImportsTarget End%0a==============================================================" />
</Target>