Hi all,
I've got a simple 'MSBuild project file in VS customization' mission:
Two projects (a web project and a class library). Class library references a third-party library consisting of some dlls and some other files which has to be in the same directory as dll files for the library to work correctly. Web project references the class library. Third-party library files has been placed into lib folder of the class library VS project. Because "Copy to output directory" cannot be used on these files (finally they has to be in bin directory, not in bin\lib directory), I've created new ItemGroup called LibFile, put the library files into this ItemGroup and to copy these files to output directory I modified AfterBuild target like this:
<Target Name="AfterBuild" Inputs="@(LibFile)" Outputs="@(LibFile->'$(OutputPath)%(filename)%(extension)')">
<Copy SourceFiles="@(LibFile)" DestinationFolder="$(OutputPath)" SkipUnchangedFiles="true" />
</Target>
As for the class library, everything works correctly - third-party library files are correctly copied to the output (bin) directory. But they are not copied to the bin directory of the web project which references this class library. I've tried many things, including adding these files to SatelliteDlls ItemGroup etc., but nothing worked.
How would a MSBuild pro go about this
Martin

VS Integration - adding items to project output groups
LonelyPixel
mruniqueid
"I've created new ItemGroup called LibFile, put the library files into this ItemGroup and to copy these files to output directory I modified AfterBuild target like this:"
If you are doing all the above things, then may be seeing the msbuild ouput log might help. Does the AfterBuild target get excuted at all
arkiboys
Xero_2007
Unfortunately, supposedly, MSBuild cannot resolve nested dependencies like that, i.e., if you want nativepart.dll in the output directory of your web proj, you must explictly list native.dll as a dependency of the web-proj. Here's the thread discussing this issue
Alternatively, you can do this: create an AfterBuild target in webproj.csproj that call the AfterBuild of the classlib.csproj. It would look something like this -
webproj.csproj
<Target Name="AfterBuild">
<MSBuild Project="path-to\classlib.csproj" Targets="AfterBuild"
Propeties="OutputPath=$(MSProjectDirectory)$(OutputPath)"/>
</Target>
Essentially, you would be running the Afterbuild target of classlib with the OutputPath pointed to the output path of the webproj.
Hope that helps.
Thomas S. Andersen
Let's say I have referenced assembly assembly.dll, which needs another two files in the same directory where this assembly is located: nativepart.dll and data.bin for example.
In the class library project I have folder "lib" and these two files are inside that folder. Because I want them to be automatically copied to the output directory upon build, but not to the "$(OutDir)\lib" but directly to $OutDir (alias output directory), I've added appropriate Copy task to the AfterBuild target.
As I said, there is no problem in this - the task works correctly, i.e. the files get copied to the output directory upon build exactly as I want. The problem is different - when I build the web project which references the class library project, those two files do not get copied to the web project directory (the referenced assembly does, of course).
So my question is simple: How do I add custom items to the project output in VS msbuild projects, so that they are recognized as project outputs and are treated as such
I guess there is probably some item group which these files has to be added to, and some target that needs to be overriden, but I couldn't find any information on this anywhere.
Hope I'm more clear now, thanks for help.
Martin