PostSharp配置项目编译文件
2011-11-06 01:40
302 查看
什么是PostSharp?
PostSharp升级到2.0之后不在完全免费。此文针对PostSharp 1.5。(2.0应该大同小异,没有测试,请各位自行测试。)
PostSharp安装之后在本地有详尽的文档。鉴于快餐文化和不要重复造轮子的思想,分享一下如何对指定的项目让PostSharp切入编译。
于此相关的非正常编译信息有:
I
“libs\PostSharp\PostSharp-1.5.targets(91,5): warning : For side-by-side compatibility, the reference to assembly PostSharp.Public should be version-specific.”
II
“warning MSB3245: Could not resolve this reference. Could not locate the assembly "PostSharp.Core".”(或其他的PostSharp.XXX)
也许还有其他的。我没遇到过,请谅解不能一一列举。
主要步骤:
1、XCOPY相关的PostSharp文件到引用目录。文件下载文后。本着宁滥勿缺的态度,文后的文件应该是有多无少,一共也就390k。(此处提供的文件是基于X64安装包的文件,或许X86也可以用,请自行测试。)
2、修改项目文件:UrProject.csproj 或 UrProject.vbcsproj
1)、添加项目引用,此处可以直接在IDE的References中添加。项目的文件的<ItemGroup>节点下,应该有如下的几个Reference
注意:
a. 上述节点中的HintPath,使用的相对路径;引用路径不正确,将出现信息II中的错误。
b. PostSharp.Public的SpecificVersion属性,默认为False,需要在IDE->refrences->PostSharp.Public->Property->SpecificVersion中修改,或在项目文件中手动修改。否则,将出现如信息I中的错误。
3、在项目文件的末端,添加PostSharp的Import信息。此信息指定PostSharp在编译时通过何处的配置文件进行切入。
先找到<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>,分别在节点上面和下面配置如上信息。据文档说,位置很重要(如下)。还特意加了粗体,我测试确认了一下,的确是忽悠的。XML文件的节点,理论上是不应该有顺序的。
Open the project file (csproj, vbproj, ...) using a text editor. At the end of the file, there should be one or more <Import .../> elements. For instance, a C# 2.0 project file ends like this:
Before the import line, insert the following text:
This property is important in case that PostSharp is enabled globally on a machine. It prevents PostSharp global targets to be included in the project when C# or VB targets will be included. Since you can never be sure that PostSharp is not installed globally the machine of another developer working on the same project, it is a good practice to define the
After the C# / VB import line, insert the following text:
4、如果不是人品特别有问题的话,应该可以正确编译了。Over!
文件下载:PostSharp 1.5 XCOPY for x64
PostSharp升级到2.0之后不在完全免费。此文针对PostSharp 1.5。(2.0应该大同小异,没有测试,请各位自行测试。)
PostSharp安装之后在本地有详尽的文档。鉴于快餐文化和不要重复造轮子的思想,分享一下如何对指定的项目让PostSharp切入编译。
于此相关的非正常编译信息有:
I
“libs\PostSharp\PostSharp-1.5.targets(91,5): warning : For side-by-side compatibility, the reference to assembly PostSharp.Public should be version-specific.”
II
“warning MSB3245: Could not resolve this reference. Could not locate the assembly "PostSharp.Core".”(或其他的PostSharp.XXX)
也许还有其他的。我没遇到过,请谅解不能一一列举。
主要步骤:
1、XCOPY相关的PostSharp文件到引用目录。文件下载文后。本着宁滥勿缺的态度,文后的文件应该是有多无少,一共也就390k。(此处提供的文件是基于X64安装包的文件,或许X86也可以用,请自行测试。)
2、修改项目文件:UrProject.csproj 或 UrProject.vbcsproj
1)、添加项目引用,此处可以直接在IDE的References中添加。项目的文件的<ItemGroup>节点下,应该有如下的几个Reference
<ItemGroup> <!-- any other references --> <Reference Include="PostSharp.Core, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b13fd38b8f9c99d7"> <HintPath>..\libs\PostSharp\PostSharp.Core.dll</HintPath> </Reference> <Reference Include="PostSharp.Laos, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b13fd38b8f9c99d7, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> <HintPath>..\libs\PostSharp\PostSharp.Laos.dll</HintPath> </Reference> <Reference Include="PostSharp.Laos.Weaver"> <HintPath>..\libs\PostSharp\PostSharp.Laos.Weaver.dll</HintPath> </Reference> <Reference Include="PostSharp.Public, Version=1.5.0.0,Culture=neutral, PublicKeyToken=b13fd38b8f9c99d7, processorArchitecture=MSIL"> <SpecificVersion>true</SpecificVersion> <HintPath>..\libs\PostSharp\PostSharp.Public.dll</HintPath> </Reference> <!-- any other references --> </ItemGroup>
注意:
a. 上述节点中的HintPath,使用的相对路径;引用路径不正确,将出现信息II中的错误。
b. PostSharp.Public的SpecificVersion属性,默认为False,需要在IDE->refrences->PostSharp.Public->Property->SpecificVersion中修改,或在项目文件中手动修改。否则,将出现如信息I中的错误。
3、在项目文件的末端,添加PostSharp的Import信息。此信息指定PostSharp在编译时通过何处的配置文件进行切入。
<PropertyGroup> <DontImportPostSharp>True</DontImportPostSharp> </PropertyGroup> <Import Project="..\libs\PostSharp\PostSharp-1.5.targets"/> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>
先找到<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>,分别在节点上面和下面配置如上信息。据文档说,位置很重要(如下)。还特意加了粗体,我测试确认了一下,的确是忽悠的。XML文件的节点,理论上是不应该有顺序的。
Open the project file (csproj, vbproj, ...) using a text editor. At the end of the file, there should be one or more <Import .../> elements. For instance, a C# 2.0 project file ends like this:
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
Before the import line, insert the following text:
<PropertyGroup> <DontImportPostSharp>True</DontImportPostSharp> </PropertyGroup>
This property is important in case that PostSharp is enabled globally on a machine. It prevents PostSharp global targets to be included in the project when C# or VB targets will be included. Since you can never be sure that PostSharp is not installed globally the machine of another developer working on the same project, it is a good practice to define the
DontImportPostSharpbefore importing main C# / VB targets. Note that it is illegal to import PostSharp targets twice in a project; you will therefore get a build error if you accidently try to do so.
After the C# / VB import line, insert the following text:
<Import Project="Path\To\PostSharp\PostSharp.targets" />
4、如果不是人品特别有问题的话,应该可以正确编译了。Over!
文件下载:PostSharp 1.5 XCOPY for x64
相关文章推荐
- IDEA 下开发web项目部署时,配置文件没有编译的问题
- IDEA下maven编译打包Java项目成jar包但是resource下配置文件打包不成功
- eclipse 项目用tomcat发布更改配置文件之后发布编译的依然是旧的
- 我用myeclipse导入了一个用eclipse开发的项目,项目上有个差报错,是里面几个页面报的假错,部署到tomcat后,tomcat配置里这个项目的running值是false,访问就报404错误,而且不编译class文件
- Eclipse android项目中配置NDK自动编译生成so文件
- IDEA将Maven项目中src源代码下的xml配置文件编译进classes
- Java maven项目编译漏掉src/main/java下的xml配置文件
- maven编译项目后配置文件查找不到的问题
- maven项目编译漏掉src/main/java下的xml配置文件
- 分享知识-快乐自己:IDEA下maven编译打包Java项目成jar包但是resource下配置文件无法编译
- 转:Maven项目编译后classes文件中没有dao的xml文件以及没有resources中的配置文件的问题解决
- 转:Maven项目编译后classes文件中没有dao的xml文件以及没有resources中的配置文件的问题解决
- android项目中配置NDK自动编译生成so文件
- maven项目编译漏掉src/main/java下的xml配置文件
- C#winform项目添加引用编译文件
- ASP.NET项目中的web.config文件里配置数据库连接并在程序代码中获取连接字符串
- java开源框架应用技巧之spring配置文件中如果有多个.hbm.xml文件的话,无论是项目开发过程中还是维护过程中修改起来都会很麻烦切容易出错
- windows下Android利用ant自动编译、修改配置文件、批量多渠道,打包生成apk文件
- 在安卓项目中单独编译某个c源文件
- java web项目中读取配置文件