![](/img/trans.png)
[英]How to include necessary dll's in InstallShield Project Assistant?
[英]How to include required reference for project in it's release .dll
在我的解決方案中,我有一個項目“ commons”,項目中有類似SpecFlow.CustomPlugin的引用。 當我構建項目時,將生成Com.Org.Commons.dll。 但是,當我將此.dll文件引用到另一個項目時(請查看附加的圖像解決方案結構 )
具有類NUnitPropertyGenerator.cs的“ SFP”還需要引用SpecFlow.CustomPlugin,該引用已包含在commons項目中。
我構建了項目Commons,將會生成Com.Org.Commons.dll。 但是,當我將Com.Org.Commons.dll包含到SFP項目中時,下面的代碼給了我錯誤,並且沒有引用Com.Org.Commons.dll。
using TechTalk.SpecFlow.Generator.Plugins;
using TechTalk.SpecFlow.Generator.UnitTestProvider;
using TechTalk.SpecFlow.Infrastructure;
[assembly: GeneratorPlugin(typeof(Com.Org.SFP.CustomNUnitProperties.SpecFlow.NUnitPropertyGenerator))]
namespace Com.Org.SFP.CustomNUnitProperties.SpecFlow
{
public class NUnitPropertyGenerator : IGeneratorPlugin
{
public void Initialize(GeneratorPluginEvents generatorPluginEvents, GeneratorPluginParameters generatorPluginParameters)
{
generatorPluginEvents.CustomizeDependencies += (sender, args) =>
{
args.ObjectContainer.RegisterTypeAs<MasterProvider, IUnitTestGeneratorProvider>();
};
}
}
}
我以為如果我在內部引用SpecFlow.CustomPlugin包的SFP項目中包含Com.Org.Commons.dll,就會引用TechTalk.SpecFlow。
預期結果應為:
包含Com.Org.Commons.dll后,SFP項目應成功構建,並應解決與TechTalk.SpecFlow相關的代碼錯誤。 從邏輯上講,這兩個項目都需要SpecFlow.CustomPlugin程序包,但是由於我將詳細信息實現隔離到commons項目,並且考慮到common項目具有包含在依賴項中的參考包,因此我應該能夠在引用Com.Org之后解決SFP項目中的錯誤。 SFP項目中的Commons.dll。
請找到.csproj文件內容
commons.csproj( https://gist.github.com/gittadesushil/100df50d4de72d61a9d57aa08c82cada )SFP.csproj( https://gist.github.com/gittadesushil/dda1af31b5351f6ef9c71e44e2ceccda )
如果需要使用SpecFlow.CustomPlugin
DLL中定義的名稱空間/類,則需要在所有直接在代碼中使用其類的項目中直接添加對該DLL的引用。 例如, TechTalk.SpecFlow.Infrastructure
看起來像是SpecFlow.CustomPlugin
中的命名空間,該命名空間正在SFP
。 在這種情況下, SFP
需要引用SpecFlow.CustomPlugin
如果你沒有使用TechTalk.SpecFlow.Infrastructure
直接SFP
那么所有你需要做的是確保CopyLocal
的財產SpecFlow.CustomPlugins
參考commons
設置為true。
您使用的是普通參考( https://gist.github.com/gittadesushil/dda1af31b5351f6ef9c71e44e2ceccda#file-sfp-csproj-L25 ),而不是ProjectReference。
正確的是
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net45</TargetFramework>
<RootNamespace>Com.Org.SFP.CustomNUnitProperties.SpecFlow</RootNamespace>
<AssemblyName>Com.Org.SFP.CustomNUnitProperties.SpecFlow.2.4.SpecFlowPlugin</AssemblyName>
<PackageId>$(AssemblyName)</PackageId>
<Description>$(PackageId)</Description>
<OutputPath>$(SolutionDir)Output\</OutputPath>
<DocumentationFile></DocumentationFile>
<IsTool>true</IsTool>
<BuildOutputTargetFolder>tools\SpecFlowPlugin.2-4</BuildOutputTargetFolder>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<WarningLevel>0</WarningLevel>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="Com.Org.Commons" />
</ItemGroup>
</Project>
普通引用不查看依賴關系圖。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.