2013-10-11 16 views
6

Sto provando ad installare i miei file csproj per la ricerca di dipendenze in una directory padre aggiungendo:utilizzando AssemblySearchPaths nei file csproj

<PropertyGroup> 
    <AssemblySearchPaths> 
     ..\Dependencies\VS2012TestAssemblies\; $(AssemblySearchPaths) 
    </AssemblySearchPaths> 
</PropertyGroup> 

ho aggiunte questo come ultimo elemento PropertyGroup a destra prima del primo ItemGroup che ha tutte le dichiarazioni di riferimento.

Purtroppo questo sta causando tutti gli altri riferimenti a non riuscire a risolvere, ad esempio:

ResolveAssemblyReferences: 
     Primary reference "Microsoft.CSharp". 
    9>C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(1578,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.CSharp". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. 
For SearchPath "..\Dependencies\VS2012TestAssemblies\". 
       Considered "..\Dependencies\VS2012TestAssemblies\Microsoft.CSharp.winmd", but it didn't exist. 
       Considered "..\Dependencies\VS2012TestAssemblies\Microsoft.CSharp.dll", but it didn't exist. 
       Considered "..\Dependencies\VS2012TestAssemblies\Microsoft.CSharp.exe", but it didn't exist. 

C'è un modo semplice per me dire MSBuild a dove cercare per le dipendenze del mio progetto? Mi rendo conto che posso usare/p: ReferencePath, tuttavia preferisco avere la logica di compilazione nei file csproj stessi piuttosto che avere i Team Build TFS dettare dove cercare, per non parlare del fatto che mi piacerebbe che fosse possibile compilare su altri macchine per sviluppatori.

Ho provato a spostare $ (AssemblySearchPaths) per essere il primo nella lista, ma questo non ha aiutato.

+0

.... – JohnZaj

risposta

10

È possibile modificare il valore della proprietà "AssemblySearchPaths" all'interno della destinazione "BeforeResolveReferences" e vedere se questo risolve il problema?

<Target Name="BeforeResolveReferences"> 
<CreateProperty 
    Value="..\Dependencies\VS2012TestAssemblies;$(AssemblySearchPaths)"> 
    <Output TaskParameter="Value" 
     PropertyName="AssemblySearchPaths" /> 
</CreateProperty> 
</Target> 
+0

Questo funziona. È grandioso Grazie! È possibile rendere ricorsivo AssemblySearchPaths? In modo che possa avere una directory 'root' per tutte le mie dipendenze ma averle organizzate nell'albero delle cartelle? – JohnZaj

+2

Controlla questo link http://www.beefycode.com/post/resolving-binary-references-in-msbuild.aspx – Isaiah4110

+0

l'ultima parte che ha creato un nuovo target che cerca la DLL – Isaiah4110

Problemi correlati