JetBrains Rider - The task factory "CodeTaskFactory" could not be loaded from the assembly - msbuild

I am trying to build a former Windows project in JetBrains Rider on a Mac. I am getting the following build error:
NuGet.targets(100, 9): [MSB4175] The task factory "CodeTaskFactory"
could not be loaded from the assembly
"/Library/Frameworks/Mono.framework/Versions/5.2.0/lib/mono/msbuild/15.0/bin/Microsoft.Build.Tasks.v4.0.dll".
Method 'Microsoft.Build.Utilities.TaskLoggingHelper..ctor' not found.
Can anyone help?

This happens because custom msbuild code or NuGet packages you use are using a pre-MSBuild 15 way of referencing MSBuild's CodeTaskFactory.
Check all of your project / build files for occurrences of UsingTask elements referencing Microsoft.Build.Tasks.v$(MSBuildToolsVersion).dll or Microsoft.Build.Tasks.v4.0.dll (or similar dll reference) and change the dll to Microsoft.Build.Tasks.Core.dll.
If the problematic code comes from a NuGet package, see if an update to the package is available or contact its authors.

Related

GitVersionTask v4 with an MSBuild-only project

This use case might be a bit off-label, but I'm hoping someone can help me...
For a number of years I've maintained a "library" of MSBuild commands -- in a file we'll call CommonTasks.targets, distributed through our internal NuGet server -- that handles various tasks needed by my company's projects. For the last few years I've utilized GitVersion v3 with it, both for generating the library's own NuGet package version numbers as well as utilizing GitVersion's GetVersion MSBuild target directly (e.g., when generating a corresponding git tag), to avoid needing to extract the GitVersion-generated version from the dependent project's assembly, post-build.
Previously (with GitVersion v3), all that was required was for my CommonTasks.targets file to import the GitVersionTask.targets file located in GitVersion's NuGet package at \build\dotnet\GitVersionTasks.targets. This targets file in turn executed the necessary UsingTask commands (particularly GitVersionTask.GetVersion) which then let me call <GetVersion ...> in my own .targets file after the import.
With v4, GitVersionTask has introduced a dependency on UtilPack.NuGet.MSBuild (which I gather helps with various NuGet commands). To start with, that meant that I needed to import its UtilPack.NuGet.MSBuild.props file, or GitVersionTask wouldn't load at all. However, having done that, I now get unexpected errors attempting to call GetVersion from within an MSBuild file. Seemingly, the GetVersion target now attempts to query all my defined NuGet repositories (nuget.org, local caches, our company server, etc.) for the packaged version of my library, and at the end I'm greeted with this error:
MSBUILD : NuGetTaskRunnerFactory error NR0001: [NuGet Error]: Unable to find package CommonTasks with version
(>= 1.37.0-gitversiontask4-0001) [C:\redacted\CommonTasks\Build.proj]
MSBUILD : NuGetTaskRunnerFactory error NR0001: - Found 108 version(s) in Source1 [ Nearest version: 1.36.3 ] [C:\redacted\CommonTasks\Build.proj]
MSBUILD : NuGetTaskRunnerFactory error NR0001: - Found 42 version(s) in Source2 [ Nearest version: 1.36.3 ] [C:\redacted\CommonTasks\Build.proj]
MSBUILD : NuGetTaskRunnerFactory error NR0001: - Found 0 version(s) in Microsoft Visual Studio Offline Packages [C:\redacted\CommonTasks\Build.proj]
MSBUILD : NuGetTaskRunnerFactory error NR0001: - Found 0 version(s) in nuget.org [C:\redacted\CommonTasks\Build.proj]
MSBUILD : Task factory error NMSBT003: Failed to find main package CommonTasks#. [C:\redacted\CommonTasks\Build.proj(47,9): error MSB4175: The task factory "Ut
ilPack.NuGet.MSBuild.NuGetTaskRunnerFactory" could not be loaded from the assembly "C:\redacted\CommonTasks\packages\UtilPack.NuGet.MSBuild.2.7.0\build\\net46\UtilPack.NuGet.MSBuild.dll". Object ref
erence not set to an instance of an object.
What I don't get is why it's attempting NuGet retrievals at all, and, even if that's the new default behavior, I don't know a way to disable that, or barring that, I don't know why it's not working. I assume the error must have something to do with this not being a normal .NET project (i.e., with no source code aside from a .targets file, no .csproj file, etc.). But my library is used by many normal .NET projects, which themselves use GitVersionTask to auto-version their assemblies.
For now I've pinned my library to GitVersionTask v3, but would very much like to figure out how to allow it to use v4 as I'd been using v3 previously. I could likely switch to using the GitVersion.CommandLine package instead, and parsing its output, but I ultimately do need these GitVersion-generated versions as MSBuild properties in order to use them as intended. And with dependent projects also using GitVersionTask (not the CLI), it's convenient to be able to use a single package for both.
Is there a way to fix what I'm doing with GitVersionTask v4, or some completely different (perhaps more elegant) way to achieve what I'm trying to do?

Cannot create controller in VS 2012 MVC 4.0

When I create new project, create a new control have no problem. But when I'm using TFS in Visual Studios 2012 to get the latest code. All code is update, I cannot create new controller. This is my alert error from VS
could not load file or assembly'System.web.mvc, vesion = 3.0.0.0,culture = neutral, pulbickeytoken = 31bf3856ad364e35' or more of its this system cannot find the file specified.
Looks like you have a missing reference to System.Web.Mvc. Got to the "References" part of your project and add the missing reference.
Alternatively you could add the relevant System.Web.Mvc.Extensions Mvc 4 NuGet package which should add all references that your solution might be missing.
There is a discrepancy in your question between the error and your tag of MVC-4. So assuming you are aiming to use MVC 4.
In Visual Studio, go to the Package Manager Console via Tools -> Library Package Manager -> Package Manager Console. and run the following commands with the source : nuget.org as answered by Shiva in a Entity Framework question.
Edit:
Uninstall the previous version of MVC 3.0 and all references to it.
Uninstall-Package Microsoft.AspNet.Mv -Force
Upgrade to MVC 4.0 to match the tag you've added to the
question
Install-Package Microsoft.AspNet.Mvc -Version 4.0.30506
Check that Entity Framework is installed. Check the project file (*.csproj, *.vbproj) references by Right clicking the project file and opening it in a text editor such as notepad++.
Rebuild or Clean (optional) your project. When you have a full compile of the project such as getting the code from TFS, it will check all the references and throw this exception. When you compile the project again this error will most likely not appear as you are not doing a full compile.
Check the TFS version of the project file for any discrepancies.
I got the same problem, the cause was a "Security Update". After this update Project references to System.Web.Mvc.dll are no longer resolved because the assembly version of System.Web.Mvc.dll was incremented.
There are two ways to solve this issue, by installing a nuguet package or by manually updating the reference to System.Web.MVC.dll (don’t use the one in the GAC)
This blog post contains a detailed explanation:
http://blogs.msdn.com/b/webdev/archive/2014/10/16/microsoft-asp-net-mvc-security-update-broke-my-build.aspx

Copy task not working in MSBuild 4

<Copy SourceFiles="#(sourceFiles)" DestinationFolder="$(destinationFolder)\"/>
This used to work fine for me in MSBuild 3.5. But since I've been trying to migrate to 4.0, MSBuild throws me this error.
The "Microsoft.Sdc.Tasks.Folder.Copy" task could not be loaded from the assembly Microsoft.Sdc.Tasks.dll. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.
I've tried putting the UsingTask, but still in vain. Any ideas?
The reason is simple,
You install http://sdctasks.codeplex.com/ in .NET 2.0 GAC. So MSBuild 2.0 or 3.5 can load it successfully.
.NET 4 uses a different GAC, so MSBuild 4 cannot find what you install in .NET 2 GAC.
Therefore, you see an error message.
My advice,
Switch to MSBuild Community Pack as suggested by http://sdctasks.codeplex.com/.
Instead of adding an MSBuild extension assembly into GAC, you should put it into your dependency folder (such as lib), and add it to source control.
When modifying your project file (such as csproj), make sure that in <UsingTask> you use the assembly path to your dependency folder.
My open source project #SNMP uses Gendarme MSBuild extension, and I have been using the above trick for a long time,
https://github.com/lextm/sharpsnmplib/blob/master/SharpSnmpLib/SharpSnmpLib.csproj

Conversion of jar to dll using ikvm

I am trying to convert a jar into dll in dotnet using IKVM but am getting this error Exception in thread "main" java.lang.ClassNotFoundException: \Location of the jar\...
CAn anyone provide some guidance..
Thanks in advance
Prerequisites -
You must have the JDK installed on your system.
Set the environment variables for the JDK.
Steps:
Open the command prompt.
Go to the ikvmc folder (ikvmc.exe comes with the ikvm package).
Enter the command ikvmc -out:myapp.dll myapp.jar
First, create a new Bindings Library project. In Xamarin Studio or Visual Studio, create a new Solution and select the Android Bindings Library template.
The template includes a Jars folder where you add your .JAR(s) to the Bindings Library project. Right-click the Jars folder and select Add > Existing Item:
Navigate to the .jar file downloaded earlier, select it and click Add:
Verify that the .jar file was successfully added to the project:
right click your jar file=>properities =>choose embedded jar
Set the build action to EmbeddedJar:
EmbeddedJar – the .JAR will be embedded in the Bindings Library.
Set the target API level for your Bindings Library
Finally, build the Bindings Library. Although some warning messages may be displayed, the Bindings Library project should build successfully and produce an output .DLL at the following location:
Projectname/bin/Debug/JarBinding.dll
Reference
https://developer.xamarin.com/guides/android/advanced_topics/binding-a-java-library/binding-a-jar/
Is it possible that you forgot reference all needed IKVM .Net dlls?
IKVM.Runtime.dll
IKVM.Reflection.dll
IKVM.OpenJDK.*.dll
I've got something similar with SmsLib .Net version
The follow wiki pages should be helpful:
http://sourceforge.net/apps/mediawiki/ikvm/index.php?title=ClassLoader
http://sourceforge.net/apps/mediawiki/ikvm/index.php?title=Ikvmc
http://sourceforge.net/apps/mediawiki/ikvm/index.php?title=Ikvmc_messages

VB.Net project shows errors on clean in VS2010

my issue is very similar to:
http://www.dotnetmonster.com/Uwe/Forum.aspx/dotnet-vb/54944/VB-Net-project-throwing-errors-when-executing-Clean-Solution
Typical errors: Unable to load referenced library X
Type IWshRuntimeLibrary.WshShell is not defined.
Interface System.IDisposable is not implemented by this class.
Namespace of type specified in the Imports Z does not contain any public members or cannot be found. Make sure the imported element name does not use any aliases.
This must have to do with a VB.net project configuration. Currently there is a setting "Treat all warnings as errors". I would like to keep that setting, but also resolve these annoying "errors".
I've experienced a similar problem and fixed it by running the following command in the VS command line tool
devenv /resetskippkgs
I'ev had problems executing Clean's via MSBuild in VS2008 when projects were registered for COM interop.
The problem is that the "Clean" target auto-generated for a solution cleans projects in the same order in which they were built.
This causes problems for projects registered for COM when MSBuild attempts to load and then unregister the assembly from COM during a "Clean".The issue occurs if the assembly has a dependency on another project because the dependency will be deleted first and therefore loading the assembly will fail and MSBuild will be unable to unregister it.
A workaround is to change the solution .cache file (which contains the targets auto-generated by MSBuild during "Build") and reverse the order of the "Clean" target. I hacked-together a quick-fix custom build task to do this as a post-build step.
No idea if this was fixed in VS2010 or indeed if this matches your problem since you don't give many specifics in your question ;)