This question might have been asked multiple times and maybe I\'m just bad at using the search functions here aswell as google but I\'ve not found an answer to this question
This question has been answered already but I figured I'll include a generic fail-safe method for copying all indirect references into your projects' output directories.
CopyIndirectDependencies.targets
and place the targets file in your project directory..csproj
or .vbproj
to include an import to the .targets
file you added. See example below.CopyIndirectDependencies.targets File Content
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<CopyIndirectDependencies
Condition="'$(CopyIndirectDependencies)'==''">true</CopyIndirectDependencies>
<CopyIndirectDependenciesPdb
Condition="'$(CopyIndirectDependenciesPdb)'==''">false</CopyIndirectDependenciesPdb>
<CopyIndirectDependenciesXml
Condition="'$(CopyIndirectDependenciesXml)'==''">false</CopyIndirectDependenciesXml>
</PropertyGroup>
<!-- BuildXxx part -->
<Target Name="CopyIndirectDependencies"
Condition="'$(CopyIndirectDependencies)'=='true'"
DependsOnTargets="DetectIndirectDependencies">
<Copy Condition="'%(IndirectDependency.FullPath)'!=''"
SourceFiles="%(IndirectDependency.FullPath)"
DestinationFolder="$(OutputPath)"
SkipUnchangedFiles="true" >
<Output TaskParameter="CopiedFiles"
ItemName="IndirectDependencyCopied" />
</Copy>
<Message Importance="low"
Condition="'%(IndirectDependencyCopied.FullPath)'!=''
and '%(IndirectDependencyCopied.Extension)'!='.pdb'
and '%(IndirectDependencyCopied.Extension)'!='.xml'"
Text="Indirect dependency copied: %(IndirectDependencyCopied.FullPath)" />
</Target>
<Target Name="DetectIndirectDependencies"
DependsOnTargets="ResolveAssemblyReferences">
<Message Importance="low"
Text="Direct dependency: %(ReferencePath.Filename)%(ReferencePath.Extension)" />
<Message Importance="low"
Text="Indirect dependency: %(ReferenceDependencyPaths.Filename)%(ReferenceDependencyPaths.Extension)" />
<!-- Creating indirect dependency list -->
<CreateItem Include="%(ReferenceDependencyPaths.FullPath)"
Condition="'%(ReferenceDependencyPaths.CopyLocal)'=='true'">
<Output TaskParameter="Include"
ItemName="_IndirectDependency"/>
</CreateItem>
<CreateItem Include="%(ReferenceDependencyPaths.RootDir)%(ReferenceDependencyPaths.Directory)%(ReferenceDependencyPaths.Filename).xml"
Condition="'%(ReferenceDependencyPaths.CopyLocal)'=='true' and '$(CopyIndirectDependenciesXml)'=='true'">
<Output TaskParameter="Include"
ItemName="_IndirectDependency"/>
</CreateItem>
<CreateItem Include="%(ReferenceDependencyPaths.RootDir)%(ReferenceDependencyPaths.Directory)%(ReferenceDependencyPaths.Filename).pdb"
Condition="'%(ReferenceDependencyPaths.CopyLocal)'=='true' and '$(CopyIndirectDependenciesPdb)'=='true'">
<Output TaskParameter="Include"
ItemName="_IndirectDependency"/>
</CreateItem>
<!-- Filtering indirect dependency list by existence -->
<CreateItem Include="%(_IndirectDependency.FullPath)"
Condition="Exists('%(_IndirectDependency.FullPath)')">
<Output TaskParameter="Include"
ItemName="IndirectDependency"/>
</CreateItem>
<!-- Creating copied indirect dependency list -->
<CreateItem Include="@(_IndirectDependency->'$(OutputPath)%(Filename)%(Extension)')">
<Output TaskParameter="Include"
ItemName="_ExistingIndirectDependency"/>
</CreateItem>
<!-- Filtering copied indirect dependency list by existence -->
<CreateItem Include="%(_ExistingIndirectDependency.FullPath)"
Condition="Exists('%(_ExistingIndirectDependency.FullPath)')">
<Output TaskParameter="Include"
ItemName="ExistingIndirectDependency"/>
</CreateItem>
</Target>
<!-- Build sequence modification -->
<PropertyGroup>
<CoreBuildDependsOn>
$(CoreBuildDependsOn);
CopyIndirectDependencies
</CoreBuildDependsOn>
</PropertyGroup>
</Project>
Sample project with import
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
...
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="CopyIndirectDependencies.targets" /> <!-- ADD THIS LINE!! -->
...
</Project>
Source: http://blog.alexyakunin.com/2009/09/making-msbuild-visual-studio-to.html
May be Microsoft's answer will be usefull: https://connect.microsoft.com/VisualStudio/feedback/details/652785/visual-studio-does-not-copy-referenced-assemblies-through-the-reference-hierarchy
Now I figured i'd add the assembly to project X to make sure that this reference is copied over to other projects using project X. This didn't happen.... So i tried setting the 'Copy Local' setting to true.
You are still talking about the Microsoft.SqlServer.Types.dll right?
I had the same issues some time ago, actually sqlserver types should not be copied and redistributed with your installation. The correct way to "install" it is downloading the sql server runtime (which is included in the sql server management tools, that's why it works for you locally).
Because it is some time ago, I'm not 100% sure if the following information is correct and will work, but simply try to install the Microsoft® System CLR Types for Microsoft® SQL Server® 2012 only. On this download page expand Install Instructions and scroll down to the CLR Types download...
Use this link for SQL Server 2008
Install this on the target server. This will only install the stuff needed to run this types dll...