我最近将解决方案升级到了Visual Studio 2013,并从2.6.2更新了测试库中对NUnit 2.6.3的引用。一切在Visual Studio中都可以正常运行,但是驱动部署系统的我的MSBuild脚本完全被破坏了。
生成文件位于生成目录中,该目录包含带有MSBuild.Community.Targets文件(已引用)的MSBuild文件夹以及包含nunit-console.exe和各种相关文件的NUnit目录。我也将它们升级到了2.6.3。
我刚收到这个错误...
'System.IO.FileLoadException:无法加载文件或程序集
'nunit.framework,版本= 2.6.0.12051,文化=中性,
PublicKeyToken = 96d09a1eb7f44a77'或其依赖项之一。的
定位的程序集的清单定义与程序集不匹配
参考。 (来自HRESULT的异常:0x80131040)
我一点都不明白-以前工作正常,所有代码都引用了2.6.2,所以我不知道2.6.0来自何处,或者我到底是如何告诉它寻找2.6.3的(这是在那里!!)
这是我的构建文件(如果有帮助的话)...
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="DeployAndPackage" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- IMPORTS -->
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildProjectDirectory)\MSBuild\MSBuild.Community.Tasks.targets" />
<UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll"/>
<!-- PROPERTIES -->
<PropertyGroup Label="BuildOptions">
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">Any CPU</Platform>
<OutputPath Condition=" '$(OutputPath)' == '' ">bin\</OutputPath>
<ProjectConfiguration Condition=" '$(Configuration)' == '' ">Debug</ProjectConfiguration>
<ProjectConfiguration Condition=" '$(Configuration)' == 'Test' ">Debug</ProjectConfiguration>
<ProjectConfiguration Condition=" '$(Configuration)' == 'Staging' ">Release</ProjectConfiguration>
<ProjectConfiguration Condition=" '$(Configuration)' == 'Live' ">Release</ProjectConfiguration>
</PropertyGroup>
<PropertyGroup Label="DirectoryPaths">
<RootDir>$(MSBuildProjectDirectory)\..\</RootDir>
<TestsDir>$(RootDir)Tests\</TestsDir>
<DatabaseDir>$(RootDir)SiansPlan.Database\</DatabaseDir>
<RelativePackageDir>$(RootDir)pkg\</RelativePackageDir>
<Solution>$(RootDir)SiansPlan.sln</Solution>
<SP_Auth>$(RootDir)SiansPlan.Authentication\SiansPlan.Authentication.csproj</SP_Auth>
<SP_Database>$(DatabaseDir)SiansPlan.Database.sqlproj</SP_Database>
<SP_Entities>$(RootDir)SiansPlan.Entities\SiansPlan.Entities.csproj</SP_Entities>
<SP_Domain>$(RootDir)SiansPlan.Domain\SiansPlan.Domain.csproj</SP_Domain>
<SP_Providers>$(RootDir)SiansPlan.Providers\SiansPlan.Providers.csproj</SP_Providers>
<SP_ApiDir>$(RootDir)SiansPlan.Api\</SP_ApiDir>
<SP_Api>$(SP_ApiDir)SiansPlan.Api.csproj</SP_Api>
<SP_Web>$(RootDir)SiansPlan.Web\SiansPlan.Web.csproj</SP_Web>
<SP_SpaDir>$(RootDir)SiansPlan.Spa\</SP_SpaDir>
<SP_Spa>$(SP_SpaDir)SiansPlan.Spa.csproj</SP_Spa>
<SP_Test_Support>$(TestsDir)SiansPlan.TestSupport\SiansPlan.TestSupport.csproj</SP_Test_Support>
<SP_Entities_Tests>$(TestsDir)SiansPlan.Entities.Tests\SiansPlan.Entities.Tests.csproj</SP_Entities_Tests>
<SP_Auth_Tests>$(TestsDir)SiansPlan.Authentication.Tests\SiansPlan.Authentication.Tests.csproj</SP_Auth_Tests>
<SP_Domain_Tests>$(TestsDir)SiansPlan.Domain.Tests\SiansPlan.Domain.Tests.csproj</SP_Domain_Tests>
<SP_Api_Tests>$(TestsDir)SiansPlan.Api.Tests\SiansPlan.Api.Tests.csproj</SP_Api_Tests>
</PropertyGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>2ae13924-f2dd-48b1-9acb-755e0ee2b0d1</ProjectGuid>
</PropertyGroup>
<!-- BUILD -->
<Target Name="Compile">
<MSBuild Projects="$(SP_Auth)" Targets="Rebuild" Properties="Configuration=$(ProjectConfiguration);Platform=$(Platform);OutputPath=bin\" />
<MSBuild Projects="$(SP_Database)" Targets="Rebuild" Properties="Configuration=$(ProjectConfiguration);Platform=$(Platform);OutputPath=bin\" />
<MSBuild Projects="$(SP_Entities)" Targets="Rebuild" Properties="Configuration=$(ProjectConfiguration);Platform=$(Platform);OutputPath=bin\" />
<MSBuild Projects="$(SP_Domain)" Targets="Rebuild" Properties="Configuration=$(ProjectConfiguration);Platform=$(Platform);OutputPath=bin\" />
<MSBuild Projects="$(SP_Providers)" Targets="Rebuild" Properties="Configuration=$(ProjectConfiguration);Platform=$(Platform);OutputPath=bin\" />
<MSBuild Projects="$(SP_Api)" Targets="Rebuild" Properties="Configuration=$(ProjectConfiguration);Platform=$(Platform);OutputPath=bin\" />
<MSBuild Projects="$(SP_Web)" Targets="Rebuild" Properties="Configuration=$(ProjectConfiguration);Platform=$(Platform);OutputPath=bin\" />
<MSBuild Projects="$(SP_Spa)" Targets="Rebuild" Properties="Configuration=$(ProjectConfiguration);Platform=$(Platform);OutputPath=bin\" />
<MSBuild Projects="$(SP_Test_Support)" Targets="Rebuild" Properties="Configuration=$(ProjectConfiguration);Platform=$(Platform);OutputPath=bin\" />
<MSBuild Projects="$(SP_Entities_Tests)" Targets="Rebuild" Properties="Configuration=$(ProjectConfiguration);Platform=$(Platform);OutputPath=bin\" />
<MSBuild Projects="$(SP_Auth_Tests)" Targets="Rebuild" Properties="Configuration=$(ProjectConfiguration);Platform=$(Platform);OutputPath=bin\" />
<MSBuild Projects="$(SP_Domain_Tests)" Targets="Rebuild" Properties="Configuration=$(ProjectConfiguration);Platform=$(Platform);OutputPath=bin\" />
<MSBuild Projects="$(SP_Api_Tests)" Targets="Rebuild" Properties="Configuration=$(ProjectConfiguration);Platform=$(Platform);OutputPath=bin\" />
</Target>
<!-- TEST -->
<Target Name="RunTests" DependsOnTargets="Compile">
<CreateItem Include="$(RootDir)Tests\*.Tests\bin\*.Tests.dll">
<Output TaskParameter="Include" ItemName="TestAssemblies" />
</CreateItem>
<NUnit Assemblies="@(TestAssemblies)" ToolPath="$(MSBuildProjectDirectory)\NUnit" DisableShadowCopy="true" />
</Target>
<!-- TRANSFORM -->
<Target Name="Transform">
<TransformXml Source="$(SP_ApiDir)\Web.config"
Transform="$(SP_ApiDir)\Web.$(Configuration).config"
Destination="$(SP_ApiDir)\Web.transformed.config"
StackTrace="False" />
<TransformXml Source="$(SP_SpaDir)\Web.config"
Transform="$(SP_SpaDir)\Web.$(Configuration).config"
Destination="$(SP_SpaDir)\Web.transformed.config"
StackTrace="False" />
</Target>
<!-- DEPLOY & PACKAGE -->
<Target Name="DeployAndPackage" DependsOnTargets="RunTests">
<CallTarget Targets="Transform"/>
<ItemGroup>
<SqlFiles Include="$(DatabaseDir)Upgrades\*.sql" />
</ItemGroup>
<RemoveDir Directories="$(RelativePackageDir)" />
<MakeDir Directories="$(RelativePackageDir)" />
<MakeDir Directories="$(RelativePackageDir)sql\" />
<Copy SourceFiles="@(SqlFiles)" DestinationFolder="$(RootDir)pkg\sql" />
</Target>
</Project>
构建的“RunTests”部分的完整输出为...
运行测试:
C:\ Development \ Clients \ SiansPlan \ source \ build \ NUnit \ nunit-console.exe
/ nologo / noshadow
C:\ Development \ Clients \ SiansPlan \ source \ build .. \ Tests \ SiansPlan.Api.Tests \ bin \ SiansPlan.Api.Tests.dll
C:\ Development \ Clients \ SiansPlan \ source \ build .. \ Tests \ SiansPlan.Api.Tests \ bin \ SiansPlan.Domain.Tests.dll
C:\ Development \ Clients \ SiansPlan \ source \ build .. \ Tests \ SiansPlan.Authentication.Tests \ bin \ SiansPlan.Authentication.Tests.dll
C:\ Development \ Clients \ SiansPlan \ source \ build .. \ Tests \ SiansPlan.Domain.Tests \ bin \ SiansPlan.Domain.Tests.dll
C:\ Development \ Clients \ SiansPlan \ source \ build .. \ Tests \ SiansPlan.Entities.Tests \ bin \ SiansPlan.Entities.Tests.dll
C:\ Development \ Clients \ SiansPlan \ source \ build .. \ Tests \ SiansPlan.Logging.Tests \ bin \ SiansPlan.Domain.Tests.dll
C:\ Development \ Clients \ SiansPlan \ source \ build .. \ Tests \ SiansPlan.Logging.Tests \ bin \ SiansPlan.Logging.Tests.dll
ProcessModel:默认DomainUsage:多次执行运行时:
net-4.5未处理的异常:System.IO.FileLoadException:可以
无法加载文件或程序集'nunit.framework,Version = 2.6.0.12051,
文化=中性,PublicKeyToken = 96d09a1eb7f44a77'或其中之一
依赖性。找到的程序集的清单定义不
匹配程序集参考。 (来自HRESULT的异常:0x80131040)
文件名:“nunit.framework,版本= 2.6.0.12051,文化=中性,
PublicKeyToken = 96d09a1eb7f44a77'
任何想法都将受到欢迎,因为我正要撞到桌子上的舞台。我已经问过我的桌子熊,橡皮鸭和Soundwave,坦白说,它们都没多大用处!
最佳答案
对于一个晦涩的问题,答案含糊不清-似乎我有一个旧的库在四处闲逛(Domain.Logging中的Tests有点赠品),导致它崩溃了。
清除失败
关于msbuild - 升级后NUnit在MSBuild中运行失败-System.IO.FileLoadException:无法加载文件或程序集nunit.framework,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23141159/