找到你要的答案

Q:How to run PostShard samples from 2.1 to 4.1?

Q:如何运行postshard样品从2.1到4.1?

After download samples from Download - Samples – PostSharp a "PostSharp Required" dialog was shown asking to install PostSharp 2.1.

I have PostSharp 4.1 installed in my machine, is there a way to run those samples using PostSharp 4.1?

After download samples from Download - Samples – PostSharp a "PostSharp Required" dialog was shown asking to install PostSharp 2.1.

我有PostSharp 4.1安装在我的机器上,有没有一种方式来运行那些样品使用PostSharp 4.1?

answer1: 回答1:

Most samples should be compatible, but are not currently officially supported.

To convert them to the new PostSharp version, you need to edit the csproj file remove the following XML:

<!-- The next section automatically prompts you to install PostSharp if needed. It is not required in normal projects. -->
<UsingTask AssemblyFile="lib\PostSharp.MSBuild.Samples.exe" TaskName="PostSharp.MSBuild.Samples.LaunchPostSharpInstaller"  />
<Target Name="PostSharp21Check" Condition="'$(PostSharp21Imported)'==''" >
    <LaunchPostSharpInstaller ProjectPath="$(MSBuildProjectFullPath)" Version="2.1" ProjectGuid="$(ProjectGuid)" BuildingProject="$(BuildingProject)" />
    <Error Text="To build this project, you must install PostSharp 2.1 on your machine or add it as a NuGet package to this project." />
</Target>
<PropertyGroup >
    <ResolveReferencesDependsOn>PostSharp21Check;$(ResolveReferencesDependsOn)</ResolveReferencesDependsOn>
</PropertyGroup>

Additionally, you need to remove all referenced PostSharp assemblies - most likely only PostSharp.dll (either when editing the csproj file or after reopening).

After reopening the project, you should add PostSharp NuGet package, which will install the current version of PostSharp.

大多数样品应该是兼容的,但目前没有正式支持。

将它们转换为新的邮政夏普版本,你需要编辑csproj文件删除下列XML:

<!-- The next section automatically prompts you to install PostSharp if needed. It is not required in normal projects. -->
<UsingTask AssemblyFile="lib\PostSharp.MSBuild.Samples.exe" TaskName="PostSharp.MSBuild.Samples.LaunchPostSharpInstaller"  />
<Target Name="PostSharp21Check" Condition="'$(PostSharp21Imported)'==''" >
    <LaunchPostSharpInstaller ProjectPath="$(MSBuildProjectFullPath)" Version="2.1" ProjectGuid="$(ProjectGuid)" BuildingProject="$(BuildingProject)" />
    <Error Text="To build this project, you must install PostSharp 2.1 on your machine or add it as a NuGet package to this project." />
</Target>
<PropertyGroup >
    <ResolveReferencesDependsOn>PostSharp21Check;$(ResolveReferencesDependsOn)</ResolveReferencesDependsOn>
</PropertyGroup>

另外,你需要删除所有引用PostSharp组件-最有可能只有PostSharp.dll(当编辑csproj文件或恢复高考后)。

恢复高考后的项目,你应该添加PostSharp NuGet包,它将安装PostSharp当前版本。

postsharp