I have complex solution with a lot of MVC web application projects which have to be built in a specific way. That's why I use custom build project and msbuild
utility to build the solution on my local machine. The thing is that the solution and all projects in it are building successfully in Visual Studio
. But when I try to build the solution via msbuild
using AspNetCompiler
I keep getting the same error:
ASPNETCOMPILER : error ASPCONFIG: Could not load file or assembly 'Duke.Owin.VkontakteMiddleware, Version=1.2.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
This error does not appear when I build solution in Visual Studio
(2013). Trying to fix the problem I've already done the following:
- All existing references in the projects of my solution are configured to
Copy local = true
- Before each build I clear (and remove) all
bin
andobj
folders of my projects. - I cleared Temporary Asp .Net files multiple times and before each build.
- All assemblies, which compiler says it can't find, are located in packages folder.
Tried to restore NuGet packages before each build:
- Downloaded NuGet
- Enabled NuGet package restore by adding
EnableNuGetPackageRestore=true
environment variable - Added
<Exec Command='$(ToolsDirectory)\nuget restore "$(Solution)"'/>
command to my build project.
Tried manually define references in build project:
<ItemGroup><Reference Include="Duke.Owin.VkontakteMiddleware"><HintPath>$(PackagesFolder)\Duke.Owin.VkontakteMiddleware.1.2.0.0\lib\net45\Duke.Owin.VkontakteMiddleware.dll</HintPath></Reference></ItemGroup>
As it is suggested here, I manually edited the project file that is failing to build and added
<Private>True</Private>
in eachReference
node that isn't found by compiler.Tried manually copy missed dlls:
<Copy SourceFiles="$(PackagesFolder)\Duke.Owin.VkontakteMiddleware.1.2.0.0\lib\net45\Duke.Owin.VkontakteMiddleware.dll" DestinationFolder="$(OutputDirectory)\bin" SkipUnchangedFiles="true" />
But, after all of the above, still no luck. Are there any more solutions?
UPDATE: If I add the assembly to GAC it actually helps, BUT some of my assemblies are installed packages from the nuget and they are not strongly named so I can't add all of them to the GAC. And, of course, registering all assemblies in the GAC is not a desirable solution.