目前,当我将 FluentMigrator.Runner nuget软件包添加到c#项目中时,它会自动安装所有其他相关的nuget软件包: FluentMigrator.Runner.Db2 , FluentMigrator.Runner .Firebird 等。
但我只需要SqlServer支持。我无法卸载所有这些辅助包,因为FluentMigrator.Runner依赖于它们。
如果我强制删除引用,我只会遇到运行时错误:
Could not load file or assembly 'FluentMigrator.Runner.Db2, Version=3.0.0.0,
Culture=neutral, PublicKeyToken=aacfc7de5acabf05' or one of its dependencies.
The system cannot find the file specified.
这使我的c#项目引用了很多无用的dll。特别是Sql Server Ce本机文件。 如果我只需要SqlServer,有没有办法摆脱Db2,Firebird和其他实现?
我使用Fluent Migrator版本3和.Net 4.7.1
答案 0 :(得分:0)
这是解决此问题的方法:
<Import Project="..\packages\FluentMigrator.Runner.SqlServerCe.3.1.3\build\netstandard2.0\FluentMigrator.Runner.SqlServerCe.targets" Condition="Exists('..\packages\FluentMigrator.Runner.SqlServerCe.3.1.3\build\netstandard2.0\FluentMigrator.Runner.SqlServerCe.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\FluentMigrator.Runner.SqlServerCe.3.1.3\build\netstandard2.0\FluentMigrator.Runner.SqlServerCe.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\FluentMigrator.Runner.SqlServerCe.3.1.3\build\netstandard2.0\FluentMigrator.Runner.SqlServerCe.targets'))" />
</Target>