<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
...
<!-- Optional, default is false: -->
<UsePostSharp>true</UsePostSharp>
<!-- Required, see the description below: -->
<DontImportPostSharp>true</DontImportPostSharp>
<!-- Optional, default is false: -->
<UseFiXml>true</UseFiXml>
<!-- Optional, default is true: -->
<CopyIndirectDependencies>false</CopyIndirectDependencies>
<!-- Optional, default is environment variable value -->
<DataObjectsDotNetPath>..\DO4</DataObjectsDotNetPath>
</PropertyGroup>
<ItemGroup>
...
<Reference Include="PostSharp.Laos, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b13fd38b8f9c99d7, processorArchitecture=MSIL" />
<Reference Include="PostSharp.Public, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b13fd38b8f9c99d7, processorArchitecture=MSIL" />
<Reference Include="Xtensive.Core, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="Xtensive.Core.Aspects, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="Xtensive.Indexing, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="Xtensive.Integrity, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="Xtensive.Storage, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="Xtensive.Storage.Model, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="Xtensive.Storage.All, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
</Reference>
</ItemGroup>
...
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(DataObjectsDotNetPath)\Common\DataObjects.Net.targets" />
...
</Project>
Let's discuss each particular line here.Properties:
- UsePoshSharp property indicates whether PostSharp must be applied to this assembly. This option is necessary only for projects declaring persistent types (Entity, Structure or SessionBound descendants), but not for projects using them (in these cases it is optional).
- DontImportPostSharp property indicates any separately installed PostSharp version (if any) must not be used. This is a required option - if you won't add corresponding line, your project won't compile on machine where PostSharp is installed with "Global PostSharp Auto-Detection" option. Installed version of PostSharp will detect indirect reference to it from any project that references DataObjects.Net assemblies (directly or indirectly), and will try to post-process its binary; but this is impossible, since now we don't install our weaver into your own PostSharp installation - it is integrated into PostSharp version we ship in Lib folder, that is used by DataObjects.Net.targets.
- UseFiXml property turns on post-processing of XML comments for this project by FiXml tool. If you'd like to use <inheritdoc/> and <see ... copy="true"/> inside your documentation, just set it to true.
- CopyIndirectDependencies ensures copying of all indirect dependencies to project output folder. This post describes why this is so convenient. Set it to false to disable this: default value of this property is true.
- DataObjectsDotNetPath property may specify relative or absolute path to DataObjects.Net. If it is omitted (that's default case), value of the same environment variable will be used. This environment variable is defined by new Install.bat (and thus by installer as well). So now it is really easy to make your DataObjects.Net-based solution compilable after XCopy: either run <DataObjects.Net root folder>\Install\Install.bat on the target machine after XCopying, or specify relative path to DataObjects.Net root folder in .csproj/.vbproj with this option (this implies you must keep Common, Bin and Lib folders from DataObjects.Net root folder inside your solution).
References:
- To PostSharp.* assemblies. They're necessary only for assemblies containing persistent types, since our aspects are inherited from types declared there. As you see, there is no necessity to specify correct <HintPath> now: appropriate search path will be provided by DataObjects.Net.targets.
- To Xtensive.* assemblies. They're necessary in almost any project using DataObjects.Net, since your own persistent types are inherited from types declared there. Again, there is no necessity to specify correct <HintPath> now: appropriate search path will be provided by DataObjects.Net.targets.
- To Xtensive.Storage.All.dll. This assembly indirectly references all the assemblies that can be loaded by DataObjects.Net in any possible configuration. So for example, it indirectly references Mono.Security.dll, which is referenced by NPgSql.dll, which is loaded when DataObjects.Net is used with PostgreSQL provider. Referencing Xtensive.Storage.All.dll in conjunction with CopyIndirectDependencies option ensures output folder will contain all the assemblies necessary to run your application in any possible configuration.
Imports:
- $(DataObjectsDotNetPath)\Common\DataObjects.Net.targets. This .targets file does all the magic that stands behind all the properties I just described. As you already know, its location depends on DataObjectsDotNetPath property value or the same environment variable.
10 comments:
Update: Added info about DontImportPostSharp property.
Please copy folders BIN, COMMON, LIB from DO4 installation path to inner solution dir in 'DO4.Libs' (here is poiting msbuild property DataObjectsDotNetPath in .csproj with value $(SolutionDir)\DO4.Libs.
All 3 projects (Common.Model, Core.Model, Console.Test) in its .csproj have set property $(DataObjectsDotNetPath) to value '$(SolutionDir)\DO4.Libs' where are libraries from DO4 in described in post.
When i build, everything seems ok, but when i run Console.Test project, it crash on line: Domain domain = Domain.Build(config);
with this exception:
Object reference not set to an instance of an object.
at Microsoft.Practices.ServiceLocation.ServiceLocator.get_Current() in c:\Home\Chris\Projects\CommonServiceLocator\main\Microsoft.Practices.ServiceLocation\ServiceLocator.cs:line 17
at Xtensive.Core.IoC.ServiceLocator.get_GlobalLocator()
Microsoft.Practices.ServiceLocation.dll!Microsoft.Practices.ServiceLocation.ServiceLocator.Current.get() Line 17 + 0x17 bytes
But when i remove <DataObjectsDotNetPath>$(SolutionDir)\DO4.Libs</DataObjectsDotNetPath> from all 3 projects .csproj then it works without above exception. That it seems to me that i missing some libraries and/or other files within my DO4.Libs, or some of yours .targets files has some error?
Sorry, forgot an example link: http://terrorix.webs.com/files/DO4.TargetsBug.zip
Please see http://forum.x-tensive.com/viewtopic.php?f=29&t=5678 - that's almost exactly your issue + workaround.
I'll check the zip.
So two remarks:
1) You must copy Microsoft.Practices.ServiceLocation.dll manually to your bin folder, or reference it directly. That's a temporary workaround, we're working on this.
2) If you place DO4 _relatively_ to your project, you, you must define DataObjectsDotNetPath properly right in your .csproj.
Hi there,
i read forum post, make modification to csproj, build all projects, check for 'Microsoft.Practices.ServiceLocation.dll' in Console.Test\bin\debug. Everything seems ok, then execption is still there.
I have these files in bin\debug of Console.Test project:
Common.Model.dll
Common.Model.pdb
Console.Test.exe
Console.Test.exe.config
Console.Test.pdb
Console.Test.vshost.exe
Console.Test.vshost.exe.config
Console.Test.vshost.exe.manifest
Core.Model.dll
Core.Model.pdb
Microsoft.Practices.ServiceLocation.dll
Microsoft.Practices.ServiceLocation.pdb
Microsoft.Practices.ServiceLocation.xml
PostSharp.Laos.dll
PostSharp.Laos.xml
PostSharp.Public.dll
PostSharp.Public.xml
Xtensive.Core.Aspects.dll
Xtensive.Core.dll
Xtensive.Indexing.dll
Xtensive.Integrity.dll
Xtensive.Modelling.dll
Xtensive.Storage.dll
Xtensive.Storage.Indexing.dll
Xtensive.Storage.Indexing.Model.dll
Xtensive.Storage.Model.dll
Xtensive.Storage.Providers.Index.dll
Xtensive.Storage.Rse.dll
I thing everything (also Microsoft.Practices.ServiceLocation.dll) is there. What am'i doing wrong?
Uploaded second demo (http://terrorix.webs.com/files/DO4.TargetsBug2.zip) which has modified .csproj with $(DataObjectsDotNetPath), please download it, copy DO4 libraries to folder DO4.Libs, build and run Console.Test, and you see an exception. Can you discover the reason of this?
Hi again,
I download the latest source code, build it, and now everything works like a charm. Version which was wrong is that you have in official download page.
Peter, does it really crash, or it is an exception caught in debugger?
Please see this post: http://forum.x-tensive.com/viewtopic.php?f=29&t=5673&p=13579&hilit=press#p13579
Sorry for alarm, i have too checked to throw exceptions in Visual.Studio, when i uncheck then it does not shows up.
I just created an issue for this.
Post a Comment