Dav*_*New 7 msbuild postsharp visual-studio nuget nuget-package
我正在使用PostSharp,我的项目文件中有以下目标描述:
<Target Name="EnsurePostSharpImported" BeforeTargets="BeforeBuild" Condition="'$(PostSharp30Imported)' == ''">
<Error Condition="!Exists('..\..\packages\PostSharp.3.1.33\tools\PostSharp.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://www.postsharp.net/links/nuget-restore." />
<Error Condition="Exists('..\..\packages\PostSharp.3.1.33\tools\PostSharp.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://www.postsharp.net/links/nuget-restore." />
</Target>
Run Code Online (Sandbox Code Playgroud)
据我所知,当通过NuGet引用PostSharp时,这会添加到项目中,并且错误条件会检查以下内容:
但,如果我有以下配置NuGet.Config和.csproj file,是第二差错情况甚至是必要的?
NuGet.Config 文件:
<configuration>
<packageRestore>
<!-- Allow NuGet to download missing packages -->
<add key="enabled" value="True" />
<!-- Automatically check for missing packages during build in Visual Studio -->
<add key="automatic" value="True" />
</packageRestore>
...
</configuration>
Run Code Online (Sandbox Code Playgroud)
.csproj 文件:
<RestorePackages>true</RestorePackages>
Run Code Online (Sandbox Code Playgroud)
据我了解,NuGet将在构建开始之前恢复丢失的包.第二个错误条件将基本上打破构建,完全没有任何理由.
注意:我使用的是Visual Studio 2013和NuGet 2.8.
这取决于恢复的完成方式以及您安装的 NuGet 版本。看起来错误消息试图涵盖三种情况:
如果您使用基于 MSBuild 的包还原,则还原将在构建期间发生,此时不会导入 PostSharp 文件,因此 $(PostSharp30Imported) 将为空,并且将显示第二条错误消息。至少我怀疑情况确实如此。
如果从命令行构建并且不使用基于 MSBuild 的包还原,那么如果 NuGet 包丢失,您将看到第一条错误消息。
如果您没有使用基于 MSBuild 的包还原,而是使用最新版本的 NuGet 从 Visual Studio 中进行构建,那么您认为包将在构建任何内容之前进行还原是正确的。因此,PostSharp 导入在执行之前就应该可供 MSBuild 使用。
| 归档时间: |
|
| 查看次数: |
5456 次 |
| 最近记录: |