I have a problem with NuGet and boost. I have installed boost library and boost_thread library and used them before without any problems in my project.
After installing boost_serialization and pulling changes from my git master repo my project broke.
Here is the git diff from the packages.config file:
1 <?xml version="1.0" encoding="utf-8"?>
2 <packages>
- <package id="boost" version="1.54.0.157" targetFramework="Native" />
- <package id="boost_chrono-vc110" version="1.54.0.157" targetFramework="Native" />
- <package id="boost_date_time-vc110" version="1.54.0.157" targetFramework="Native" />
- <package id="boost_system-vc110" version="1.54.0.157" targetFramework="Native" />
- <package id="boost_thread-vc110" version="1.54.0.157" targetFramework="Native" />
3 + <package id="boost" version="1.55.0.10" targetFramework="Native" />
4 + <package id="boost_chrono-vc110" version="1.55.0.10" targetFramework="Native" />
5 + <package id="boost_date_time-vc110" version="1.55.0.10" targetFramework="Native" />
6 + <package id="boost_serialization-vc110" version="1.55.0.10" targetFramework="Native" />
7 + <package id="boost_system-vc110" version="1.55.0.10" targetFramework="Native" />
8 + <package id="boost_thread-vc110" version="1.55.0.10" targetFramework="Native" />
9 </packages>
Relevant section of git diff from the vcxproj file:
<ImportGroup Label="ExtensionTargets">
- <Import Project="packages\boost.1.54.0.157\build\native\boost.targets" Condition="Exists('packages\boost.1.54.0.157\build\native\boost.targets')" />
- <Import Project="packages\boost_thread-vc110.1.54.0.157\build\native\boost_thread-vc110.targets" Condition="Exists('packages\boost_thread-vc110.1.54.0.157\build\native\boost_thread-vc110.targets')" />
- <Import Project="packages\boost_system-vc110.1.54.0.157\build\native\boost_system-vc110.targets" Condition="Exists('packages\boost_system-vc110.1.54.0.157\build\native\boost_system-vc110.targets')" />
- <Import Project="packages\boost_date_time-vc110.1.54.0.157\build\native\boost_date_time-vc110.targets" Condition="Exists('packages\boost_date_time-vc110.1.54.0.157\build\native\boost_date_time-vc110.targets')" />
- <Import Project="packages\boost_chrono-vc110.1.54.0.157\build\native\boost_chrono-vc110.targets" Condition="Exists('packages\boost_chrono-vc110.1.54.0.157\build\native\boost_chrono-vc110.targets')" />
+ <Import Project="packages\boost_chrono-vc110.1.55.0.10\build\native\boost_chrono-vc110.targets" Condition="Exists('packages\boost_chrono-vc110.1.55.0.10\build\native\boost_chrono-vc110.targets')" />
+ <Import Project="packages\boost_date_time-vc110.1.55.0.10\build\native\boost_date_time-vc110.targets" Condition="Exists('packages\boost_date_time-vc110.1.55.0.10\build\native\boost_date_time-vc110.targets')" />
+ <Import Project="packages\boost_system-vc110.1.55.0.10\build\native\boost_system-vc110.targets" Condition="Exists('packages\boost_system-vc110.1.55.0.10\build\native\boost_system-vc110.targets')" />
+ <Import Project="packages\boost_thread-vc110.1.55.0.10\build\native\boost_thread-vc110.targets" Condition="Exists('packages\boost_thread-vc110.1.55.0.10\build\native\boost_thread-vc110.targets')" />
+ <Import Project="packages\boost_serialization-vc110.1.55.0.10\build\native\boost_serialization-vc110.targets" Condition="Exists('packages\boost_serialization-vc110.1.55.0.10\build\native\boost_serialization-vc110.targets')" />
+ <Import Project="packages\boost.1.55.0.10\build\native\boost.targets" Condition="Exists('packages\boost.1.55.0.10\build\native\boost.targets')" />
</ImportGroup>
It seems like the version of the dependency was updated too. I tried to change it back to 1.54 but it didn't solve the problem either. I get errors like:
IntelliSense: cannot open source file "boost/archive/text_oarchive.hpp"
I tried including it with both
#include <boost/archive/text_oarchive.hpp>
and
#include "boost/archive/text_oarchive.hpp"
How do I solve this?
EDIT1: Additional info is, that I have started using GitHub instead of TortoiseGit. Don't know if this matters.
The problem got solved by reinstalling the NuGet extension.
Related
The application I am working on has several projects, including an "Infrastructure" (.Net Standard) where the dbContext is defined, a WinForms project (.Net Framework), and a ASP.Net web project (.Net Framework). The web project is only used for Web Services (asmx).
The issue I am experiencing is that whenever I call .Include() on a IQueryable in order to include a collection navigation property from within the web project, I receive an ArgumentNullException thrown by EntityFrameworkCore.
For example:
context.Reports.Include(e => e.ReportParamters).ToList();
Value cannot be null. Parameter name: frameworkName
at Microsoft.EntityFrameworkCore.Metadata.Internal.ClrCollectionAccessorFactory.Create(INavigation navigation)
at Microsoft.EntityFrameworkCore.Metadata.Internal.Navigation.<>c.<get_CollectionAccessor>b__21_0(Navigation n)
at Microsoft.EntityFrameworkCore.Internal.NonCapturingLazyInitializer.EnsureInitialized[TParam,TValue](TValue& target, TParam param, Func`2 valueFactory)
at Microsoft.EntityFrameworkCore.Metadata.Internal.Navigation.get_CollectionAccessor()
at Microsoft.EntityFrameworkCore.NavigationExtensions.GetCollectionAccessor(INavigation navigation)
at Microsoft.EntityFrameworkCore.Query.RelationalShapedQueryCompilingExpressionVisitor.CustomShaperCompilingExpressionVisitor.VisitExtension(Expression extensionExpression)
at System.Linq.Expressions.Expression.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at System.Linq.Expressions.ExpressionVisitor.VisitBlock(BlockExpression node)
at System.Linq.Expressions.BlockExpression.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at System.Linq.Expressions.ExpressionVisitor.VisitConditional(ConditionalExpression node)
at System.Linq.Expressions.ConditionalExpression.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at System.Linq.Expressions.ExpressionVisitor.VisitBlock(BlockExpression node)
at System.Linq.Expressions.BlockExpression.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at System.Linq.Expressions.ExpressionVisitor.VisitLambda[T](Expression`1 node)
at System.Linq.Expressions.Expression`1.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at Microsoft.EntityFrameworkCore.Query.RelationalShapedQueryCompilingExpressionVisitor.VisitShapedQueryExpression(ShapedQueryExpression shapedQueryExpression)
at Microsoft.EntityFrameworkCore.Query.ShapedQueryCompilingExpressionVisitor.VisitExtension(Expression extensionExpression)
at System.Linq.Expressions.Expression.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at Microsoft.EntityFrameworkCore.Query.QueryCompilationContext.CreateQueryExecutor[TResult](Expression query)
at Microsoft.EntityFrameworkCore.Storage.Database.CompileQuery[TResult](Expression query, Boolean async)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult](IDatabase database, Expression query, IModel model, Boolean async)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass9_0`1.<Execute>b__0()
at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQueryCore[TFunc](Object cacheKey, Func`1 compiler)
at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func`1 compiler)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query)
at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute[TResult](Expression expression)
at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1.GetEnumerator()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at TRYADWebService.TRYADWebService.ItemWithNoLocationReport(String parameters) in C:\VisualStudioProjects\TRYAD\TRYADWebService\TRYADWebService.asmx.cs:line 435
I only get this error when the WinForms project calls a WebService method (which in turn calls code that includes the query). For development purposes the WinForms project references the web service using "localhost". The exact same EF query works when called directly from the WinForms project, and any query that does not use eager-loading works from the web project.
Not sure if this is relevant, but I recently converted the Infrastructure project from .Net Framework to .Net Standard and updated all the projects in the solution to use PackageReferences instead of package.config files. Unfortunately, it seems that ASP.Net web projects do not support PackageReferences, so I had to add all of the packages used in the other projects (including transitive dependencies) to the web project's package.config file. Here is the package.config file from the web project:
Web project's package.config
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Castle.Core" version="4.4.0" targetFramework="net48" />
<package id="Microsoft.Bcl.AsyncInterfaces" version="1.1.1" targetFramework="net48" />
<package id="Microsoft.Bcl.HashCode" version="1.1.1" targetFramework="net48" />
<package id="Microsoft.Data.SqlClient" version="1.1.3" targetFramework="net48" />
<package id="Microsoft.Data.SqlClient.SNI" version="1.1.0" targetFramework="net48" />
<package id="Microsoft.EntityFrameworkCore" version="3.1.23" targetFramework="net48" />
<package id="Microsoft.EntityFrameworkCore.Abstractions" version="3.1.23" targetFramework="net48" />
<package id="Microsoft.EntityFrameworkCore.Analyzers" version="3.1.23" targetFramework="net48" />
<package id="Microsoft.EntityFrameworkCore.Proxies" version="3.1.23" targetFramework="net48" />
<package id="Microsoft.EntityFrameworkCore.Relational" version="3.1.23" targetFramework="net48" />
<package id="Microsoft.EntityFrameworkCore.SqlServer" version="3.1.23" targetFramework="net48" />
<package id="Microsoft.Extensions.Caching.Abstractions" version="3.1.23" targetFramework="net48" />
<package id="Microsoft.Extensions.Caching.Memory" version="3.1.23" targetFramework="net48" />
<package id="Microsoft.Extensions.Configuration" version="3.1.23" targetFramework="net48" />
<package id="Microsoft.Extensions.Configuration.Abstractions" version="3.1.23" targetFramework="net48" />
<package id="Microsoft.Extensions.Configuration.Binder" version="3.1.23" targetFramework="net48" />
<package id="Microsoft.Extensions.DependencyInjection" version="3.1.23" targetFramework="net48" />
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="3.1.23" targetFramework="net48" />
<package id="Microsoft.Extensions.Logging" version="3.1.23" targetFramework="net48" />
<package id="Microsoft.Extensions.Logging.Abstractions" version="3.1.23" targetFramework="net48" />
<package id="Microsoft.Extensions.Options" version="3.1.23" targetFramework="net48" />
<package id="Microsoft.Extensions.Primitives" version="3.1.23" targetFramework="net48" />
<package id="Microsoft.Identity.Client" version="3.0.8" targetFramework="net48" />
<package id="Microsoft.IdentityModel.JsonWebTokens" version="5.5.0" targetFramework="net48" />
<package id="Microsoft.IdentityModel.Logging" version="5.5.0" targetFramework="net48" />
<package id="Microsoft.IdentityModel.Protocols" version="5.5.0" targetFramework="net48" />
<package id="Microsoft.IdentityModel.Protocols.OpenIdConnect" version="5.5.0" targetFramework="net48" />
<package id="Microsoft.IdentityModel.Tokens" version="5.5.0" targetFramework="net48" />
<package id="Microsoft.Linq.Translations" version="2.0.0" targetFramework="net48" />
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net48" />
<package id="System.Buffers" version="4.5.1" targetFramework="net48" />
<package id="System.Collections.Immutable" version="1.7.1" targetFramework="net48" />
<package id="System.ComponentModel.Annotations" version="5.0.0" targetFramework="net48" />
<package id="System.Data.Common" version="4.3.0" targetFramework="net48" />
<package id="System.Diagnostics.DiagnosticSource" version="4.7.1" targetFramework="net48" />
<package id="System.IdentityModel.Tokens.Jwt" version="5.5.0" targetFramework="net48" />
<package id="System.Memory" version="4.5.4" targetFramework="net48" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net48" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.7.1" targetFramework="net48" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net48" />
</packages>
update
If the DbContext is configured to allow lazy-loading and I don't use eager-loading, I don't get an exception, but the collection is empty. In the following example, the reports variable is not empty, but the reportWithParams variable is null. This is despite the EF query explicitly filtering to only reports with parameters, and lazy-loading being enabled.
var reports = context.Reports.Where(e => e.ReportParameters.Any()).ToList();
var reportWithParams = reports.FirstOrDefault(e => e.ReportParameters.Any());
which IDE do the config file(package.des and xxx.prj ) belong to?
filename is xxx.prj and package.des
the content of package.des:
<?xml version="1.0" encoding="gb2312"?>
<proje target="market" targettype="exe" hasdebug="yes" hasmap="no" hasprofile="no" multithread="yes" warninglevel="2" workdir="." libs="" cppflags="-g -ggdb3 -fpermissive" ldflags="" arflags="">
<package name="utils" dir="../../src/base/utils"/>
<package name="ini" dir="../../src/base/ini"/>
<package name="json" dir="../../src/base/json"/>
<package name="redis" dir="../../src/base/redis"/>
<package name="printfc" dir="../../src/base/printfc"/>
<package name="thread" dir="../../src/base/thread"/>
<package name="baseexchapi" dir="../../src/business/engine"/>
<package name="Thostlink" dir="../../src/business/ctp"/>
<package name="linkmanager" dir="../../src/business/linkmanager"/>
<package name="market" dir="../../src/business/market"/>
</project>
the content of xxx.prj:
<?xml version="1.0" encoding="gb2312"?>
<packageDefine name="utils" version="1" type="cpp" includedir="." platform="all">
<parameter/>
<depend>
<package name="ini" version="1"/>
<package name="printfc" version="1"/>
</depend>
<cppfile>
<file name="Lib.cpp"/>
<file name="Logger.cpp"/>
</cppfile>
<headfile>
<file name="Lib.h"/>
<file name="Logger.h"/>
<file name="global.h"/>
</headfile>
<command/>
</packageDefine>
enter image description here
enter image description here
I try to include opengl via nuget.
This is my packages.config
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="boost" version="1.64.0.0" targetFramework="Native" />
<package id="boost_atomic-vc140" version="1.64.0.0" targetFramework="native" />
<package id="boost_chrono-vc140" version="1.64.0.0" targetFramework="native" />
<package id="boost_date_time-vc140" version="1.64.0.0" targetFramework="native" />
<package id="boost_filesystem-vc140" version="1.64.0.0" targetFramework="native" />
<package id="boost_log_setup-vc140" version="1.64.0.0" targetFramework="native" />
<package id="boost_log-vc140" version="1.64.0.0" targetFramework="native" />
<package id="boost_system-vc140" version="1.64.0.0" targetFramework="native" />
<package id="boost_thread-vc140" version="1.64.0.0" targetFramework="native" />
<package id="boost_unit_test_framework-vc140" version="1.64.0.0" targetFramework="native" />
<package id="glew.v140" version="1.12.0" targetFramework="native" />
<package id="glfw" version="3.2.1" targetFramework="native" />
<package id="glfw.redist" version="3.2.1" targetFramework="native" />
<package id="GLMathematics" version="0.9.5.4" targetFramework="native" />
<package id="lua" version="5.3.3" targetFramework="native" />
<package id="lua.redist" version="5.3.3" targetFramework="native" />
<package id="nupengl.core" version="0.1.0.1" targetFramework="native" />
<package id="nupengl.core.redist" version="0.1.0.1" targetFramework="native" />
<package id="sdl2" version="2.0.5" targetFramework="native" />
<package id="sdl2.redist" version="2.0.5" targetFramework="native" />
<package id="turtle" version="1.2.6" targetFramework="native" />
<package id="unofficial.flayan.glm" version="0.9.8.4" targetFramework="Native" />
</packages>
It should contain all I need however i am getting an error:
LNK2019: unresolved external symbol __imp__glDrawElements#16
I can "fix" that by including opengl32.lib.
#pragma comment(lib, "opengl32.lib")
But I wonder if I am missing something in my packages. I was under the impression that one just adds the packages and they include the libraries into the build.
Am I misusing nuget, is there something else I should have done?
Am I misusing nuget, is there something else I should have done?
No, do not need to do anything else but just including the opengl32.lib.
glDrawElements is a "core" OpenGL feature. This function resides in opengl32.dll, which you unfortunately forgot to include in your linking libs.
Besides, Some libraries support auto-linking mechanism (for example, freeglut), that is, the header file contains a line like #prgama comment(lib, "lib1_name.lib").
To resolve that LNK error, just include the opengl32.lib by the syntax:
#pragma comment(lib, "opengl32.lib")
I started with standard Sitecore.Kernel and Sitecore.Nexus. Sitecore gives pretty descriptive error message here, so I added DependencyInjection as well. It brings lots of dependencies and they are not shown in config belo. As you can see I use *.NoReferences version of Sitecore packages to control dependencies.
<packages>
<package id="Microsoft.Extensions.DependencyInjection" version="1.0.0" targetFramework="net452" />
<package id="Sitecore.FakeDb" version="1.2.2" targetFramework="net452" />
<package id="Sitecore.Kernel.NoReferences" version="8.2.160729" targetFramework="net452" developmentDependency="true" />
<package id="Sitecore.Nexus.NoReferences" version="8.2.160729" targetFramework="net452" developmentDependency="true" />
</packages>
After that I stuck. I got an error that did not provide much clue on what is missed:
System.NullReferenceException : Object reference not set to an instance of an object.
at Sitecore.Configuration.DefaultFactory.CreateType(XmlNode configNode, String[] parameters, Boolean assert)
at Sitecore.Configuration.DefaultFactory.CreateFromTypeName(XmlNode configNode, String[] parameters, Boolean assert)
at Sitecore.Configuration.DefaultFactory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert, IFactoryHelper helper)
at Sitecore.Configuration.DefaultFactory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert)
at Sitecore.Configuration.DefaultFactory.CreateObject(String configPath, String[] parameters, Boolean assert)
at Sitecore.Configuration.DefaultFactory.CreateObject(String configPath, Boolean assert)
at Sitecore.Configuration.DefaultFactory.GetDatabase(String name, Boolean assert)
at Sitecore.Configuration.DefaultFactory.GetDatabase(String name)
at Sitecore.Configuration.Factory.GetDatabase(String name)
at Sitecore.Data.Database.GetDatabase(String databaseName)
at Sitecore.FakeDb.Db..ctor(String databaseName)
at Sitecore.FakeDb.Db..ctor()
at SitecoreTests.Class1.HowToCreateSimpleItem() in C:\prog\temp\SitecoreTests\SitecoreTests\Class1.cs:line 17
So, what is missing to make simple Fake DB test work?
After trying all packages referenced as dependencies in full Sitecore.Kernel I ended with this setup:
<packages>
<package id="Lucene.Net" version="3.0.3" targetFramework="net452" />
<package id="Microsoft.Extensions.DependencyInjection" version="1.0.0" targetFramework="net452" />
<package id="Sitecore.FakeDb" version="1.2.2" targetFramework="net452" />
<package id="Sitecore.Kernel.NoReferences" version="8.2.160729" targetFramework="net452" developmentDependency="true" />
<package id="Sitecore.Logging.NoReferences" version="8.2.160729" targetFramework="net452" developmentDependency="true" />
<package id="Sitecore.Nexus.NoReferences" version="8.2.160729" targetFramework="net452" developmentDependency="true" />
</packages>
It is clear now that Sitecore cannot start without Sitecore.Logging.
Lucene.Net required as well, but error for it is much more helpfull:
System.IO.FileNotFoundException : Could not load file or assembly
'Lucene.Net, Version=3.0.3.0, Culture=neutral,
PublicKeyToken=85089178b9ac3181' or one of its dependencies. The
system cannot find the file specified.
P.S. If you do not care about referencing extra DLLs you can add only two packages to make you test work - Sitecore.Nexus (without .NoReferences) and Microsoft.Extensions.DependencyInjection
Here is the list of packages I used in the Fortis unit test project:
<packages>
<package id="AutoFixture" version="3.0.1" targetFramework="net452" />
<package id="Lucene.Net" version="3.0.3" targetFramework="net452" />
<package id="Microsoft.AspNet.Mvc" version="3.0.50813.1" targetFramework="net452" />
<package id="Microsoft.AspNet.Razor" version="1.0.20105.408" targetFramework="net452" />
<package id="Microsoft.AspNet.WebPages" version="1.0.20105.408" targetFramework="net452" />
<package id="Microsoft.Extensions.DependencyInjection" version="1.0.0" targetFramework="net452" />
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="1.0.0" targetFramework="net452" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net452" />
<package id="NSubstitute" version="1.10.0.0" targetFramework="net452" />
<package id="RazorGenerator.Mvc" version="2.4.7" targetFramework="net452" />
<package id="SharpZipLib" version="0.86.0" targetFramework="net452" />
<package id="Sitecore.Abstractions.NoReferences" version="8.2.160729" targetFramework="net452" developmentDependency="true" />
<package id="Sitecore.Analytics.NoReferences" version="8.2.160729" targetFramework="net452" developmentDependency="true" />
<package id="Sitecore.Buckets.NoReferences" version="8.2.160729" targetFramework="net452" developmentDependency="true" />
<package id="Sitecore.ContentSearch.Linq.NoReferences" version="8.2.160729" targetFramework="net452" developmentDependency="true" />
<package id="Sitecore.ContentSearch.NoReferences" version="8.2.160729" targetFramework="net452" developmentDependency="true" />
<package id="Sitecore.FakeDb" version="1.1.3" targetFramework="net452" />
<package id="Sitecore.FakeDb.AutoFixture" version="1.1.3" targetFramework="net452" />
<package id="Sitecore.FakeDb.NSubstitute" version="1.1.3" targetFramework="net452" />
<package id="Sitecore.FakeDb.Serialization" version="1.1.3" targetFramework="net452" />
<package id="Sitecore.Kernel.NoReferences" version="8.2.160729" targetFramework="net452" developmentDependency="true" />
<package id="Sitecore.Logging.NoReferences" version="8.2.160729" targetFramework="net452" developmentDependency="true" />
<package id="Sitecore.Nexus.NoReferences" version="8.2.160729" targetFramework="net452" developmentDependency="true" />
<package id="System.Collections" version="4.0.11" targetFramework="net452" />
<package id="System.Collections.Concurrent" version="4.0.12" targetFramework="net452" />
<package id="System.ComponentModel" version="4.0.1" targetFramework="net452" />
<package id="System.Diagnostics.Debug" version="4.0.11" targetFramework="net452" />
<package id="System.Globalization" version="4.0.11" targetFramework="net452" />
<package id="System.Linq" version="4.1.0" targetFramework="net452" />
<package id="System.Linq.Expressions" version="4.1.0" targetFramework="net452" />
<package id="System.Reflection" version="4.1.0" targetFramework="net452" />
<package id="System.Resources.ResourceManager" version="4.0.1" targetFramework="net452" />
<package id="System.Runtime.Extensions" version="4.1.0" targetFramework="net452" />
<package id="System.Threading" version="4.0.11" targetFramework="net452" />
<package id="System.Threading.Tasks" version="4.0.11" targetFramework="net452" />
<package id="WebActivatorEx" version="2.0.3" targetFramework="net452" />
<package id="xunit" version="2.1.0" targetFramework="net452" />
<package id="xunit.abstractions" version="2.0.0" targetFramework="net452" />
<package id="xunit.assert" version="2.1.0" targetFramework="net452" />
<package id="xunit.core" version="2.1.0" targetFramework="net452" />
<package id="xunit.extensibility.core" version="2.1.0" targetFramework="net452" />
<package id="xunit.extensibility.execution" version="2.1.0" targetFramework="net452" />
<package id="xunit.runner.visualstudio" version="2.1.0" targetFramework="net452" />
</packages>
Also make sure you have your /App_Config/Include folder setup for your config: Here is the Fortis one
I have a very simple test as shown below.
I try to freeze my two dependencies using the AutoDataAttribute + AutoMoqCustomization.
class AutoMoqDataAttribute : AutoDataAttribute
{
public AutoMoqDataAttribute()
: base(new Fixture().Customize(new AutoMoqCustomization()))
{ }
}
public class PrBatchEndorseBrokerTest
{
[Theory, AutoMoqData]
public void Process_ValidContext_CallsK2Workflows(
[Frozen]Mock<IK2Datasource> k2,
[Frozen]Mock<IAppConfiguration> config,
PrBatchEndorseBroker sut)
{
// Arrange
var data = new Dictionary<string, object>
{
["Workflow"] = #"KLPurchaseRequest\PR",
["Activity"] = "Endorser",
["ViewFormURL"] = "/Form/KLPurchaseRequestApproval.Form",
["PositiveOutcome"] = "Endorse",
["NegativeOutcome"] = "Reject"
};
// Act
sut.Process();
// Assert
k2.Verify(x =>
x.StartInstance(It.IsAny<string>(),
It.Is<Dictionary<string, object>>(d =>
data.Keys.All(k => d[k] == data[k])))
, Times.Once());
}
}
For some reasons, when i run this test, i'm getting the following error:
System.InvalidOperationException: No data found for BlackBox.Stakhanov.Broker.Test.PrBatchEndorseBrokerTest.Process_ValidContext_CallsK2Workflows
I tried many things and i can't make it work! I think i'm missing something big and probably obvious!
Packages I'm using:
<package id="AutoFixture" version="3.47.8" targetFramework="net452" />
<package id="AutoFixture.AutoMoq" version="3.47.8" targetFramework="net452" />
<package id="AutoFixture.Xunit" version="3.47.8" targetFramework="net461" />
<package id="Castle.Core" version="3.3.3" targetFramework="net461" />
<package id="Moq" version="4.5.10" targetFramework="net461" />
<package id="xunit" version="2.1.0" targetFramework="net461" />
<package id="xunit.abstractions" version="2.0.0" targetFramework="net452" />
<package id="xunit.assert" version="2.1.0" targetFramework="net461" />
<package id="xunit.core" version="2.1.0" targetFramework="net461" />
<package id="xunit.extensibility.core" version="2.1.0" targetFramework="net461" />
<package id="xunit.extensibility.execution" version="2.1.0" targetFramework="net461" />
<package id="xunit.extensions" version="1.9.0.1566" targetFramework="net461" />
When using xUnit.net 2, you should use AutoFixture.Xunit2, not AutoFixture.Xunit.
You'll notice in your package list that you have xunit.extensions version 1.9.0.1566, which isn't compatible with xUnit.net 2.