G1ANT SDK installation for VS 2019 - g1ant

I cloned the repository at the G1ANT.Robot github page and opened G1ANT.Sdk.sln in VS Studio 2019 CE 16.1.5, Win10 Pro with latest updates. I left the default build properties as "Debug" and "AnyCPU". The following error can't be resolved, as I don't have the required files on my system:
Severity Code Description Project File Line Suppression State
Warning Could not resolve this reference. Could not locate the assembly "Microsoft.VisualStudio.CoreUtility, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. G1ANT.AddonTemplate
There are other errors, all seemingly related to dependencies on an earlier version or versions of VS (some I believe to be v14.0 dependent, some to be v15.0 dependent).
I do have the Microsoft.VisualStudio.CoreUtility available, but the version is 16.0 (i.e. VS 2019). In short, it appears that compilation may require an earlier version of VS than the one I have. Installing such an earlier version is not an option for me.
Thanks,
burque505

Yes, file /G1ANT.Sdk/G1ANT.Sdk/source.extension.vsixmanifest should be changed:
<Installation>
<InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[15.0,]" />
<InstallationTarget Id="Microsoft.VisualStudio.Pro" Version="[15.0,]" />
<InstallationTarget Id="Microsoft.VisualStudio.Enterprise" Version="[15.0,]" />
</Installation>
<Dependencies>
<Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" d:Source="Manual" Version="[4.6.1,)" />
</Dependencies>
You can download the correct installation: https://github.com/G1ANT-Robot/G1ANT.Sdk/raw/master/G1ANT.Sdk.vsix
I believe it will help :)

Related

Project doesn't compile after upgrading from Visual Studio 2017 to 2019

I can't understand the warnings and errors from Visual Studio 2019. It seems that all the references to the packages of the project are no longer working after the upgrade from Visual Studio 2017.
There are the initial lines of the log when I compile the solution.
1>------ Build started: Project: ClientServerUpload, Configuration: Debug Any CPU ------
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.Text.Encoding.CodePages". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3243: No way to resolve conflict between "System.Text.Encoding.CodePages, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.Text.Encoding.CodePages". Choosing "System.Text.Encoding.CodePages, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" arbitrarily.
1> No way to resolve conflict between "FSharp.Core, Version=4.4.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "FSharp.Core, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". Choosing "FSharp.Core, Version=4.4.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" arbitrarily.
1> No way to resolve conflict between "FSharp.Core, Version=4.4.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "FSharp.Core, Version=4.4.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". Choosing "FSharp.Core, Version=4.4.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" arbitrarily.
1> Consider app.config remapping of assembly "FSharp.Core, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" from Version "4.4.3.0" [] to Version "4.7.0.0" [\\mypath\packages\FSharp.Core.4.7.0\lib\net45\FSharp.Core.dll] to solve conflict and get rid of warning.
There are many other lines after the above, but anyway I can't see what is going wrong. For example, I pick the first message, about "System.Text.Encoding.CodePages". There a warning saying "Could not locate the assembly" and another about a conflict between Version=4.1.3.0 and a reference with no version. But from where does it look at Version=4.1.3.0? In the pacakge.config there is a line:
<package id="System.Text.Encoding.CodePages" version="4.7.0" targetFramework="net461" />
and if I edit the .proj file I see:
<Reference Include="System.Text.Encoding.CodePages"> <HintPath>..\packages\System.Text.Encoding.CodePages.4.7.0\lib\net461\System.Text.Encoding.CodePages.dll</HintPath>
</Reference>
and the HintPath is indeed there. Similar doubts for all the other messages and errors.
Only another example, why is it searching FSharp.Core, Version=4.4.1.0?
Again I have
<ItemGroup>
<Reference Include="FSharp.Core">
<HintPath>..\packages\FSharp.Core.4.7.0\lib\net45\FSharp.Core.dll</HintPath>
</Reference>
in the proj file and in the packages.config
<package id="FSharp.Core" version="4.7.0" targetFramework="net461" />
All the configurations I'm aware of seem correct to me, and the whole solution was completely fine with Visual Studio 2017. The project was built with WebSharper template, I don't know if/how this is relevant, however I also reinstalled WebSharper VSIX, after upgrading to Visual Studio 2019, and I didn't receive any error.
Aside from deleting and restoring all the packages, looking at the .proj file, cleaning and rebuilding the solution, what other options do I have? At what else should I look? I know I can add remapping to the Web.config, but I don't think it is the solution (not even a workaround). For your info, after many hours I managed to get a release with many (strange) lines of remapping and by manually (!) copying some files (including FSharp.Core) from the packages to the bin folder, that is clearly not an acceptable way to proceed.
I seem to recall something similar when I upgraded an F# project from VS2015 to 2017.
The solution was to update the version of the F# runtime (FSharp.Core.dll) in the project properties.
Looking at the .fsproj for a .NET Core 3.0 F# project: the F# runtime is not actually listed, so must be an implicit dependency: maybe removing it would also work.
Step 0
I've restored an old commit of my project to better describe the original situation and to track all the steps to resolve it.
Before the following 2 operations, I had to nuget upgrade from FSharp.Core 4.6 to 4.7, for a problem specific to WebSharper: the Scripts were not produced.
Step 1
I had to edit the .proj file to delete some reference lines, sort of duplicated.
Here is an example for FSharp.Core, but I did the same for many others (I don't know what exactly originated this problem but removing those lines seems to have done the trick for me)
<Reference Include="FSharp.Core">
<HintPath>..\packages\FSharp.Core.4.7.0\lib\net45\FSharp.Core.dll</HintPath>
</Reference>
<Reference Include="FSharp.Core" />
In the above case I deleted the last line (and all the other similar lines without a version reference under a tag containing the version of the same package)
Step 2
Then I copied and pasted all the <dependentAssembly> from the Visual Studio output to the Web.config. Again I don't understand wht they are many more than the ones needed for Visual Studio 2017, but these 2 operations apparently solved my issue.

Cannot resolve dependency to assembly FSharp.Core 4.4.1.0 when using VS 2017

I have been developing in VS 2015 and F# 4.0 (4.4.0.0) for quite some time.
With the release of VS 2017, I want to open solutions in the newest VS for development work, but still for a while keep the projects as VS 2015, F# 4.0, .NET 4.5.2. The build server will also have to use VS 2015 for a while.
As far as I can remember, this kind of scenario has not been problematic in earlier VS version upgrades, but then I don't think I used F# at that time.
I opened the solution and tried to compile. I get this error in a C# application project. (There are other C# applications, and at least one references an F# library.)
Unknown build error, 'Cannot resolve dependency to assembly 'FSharp.Core, Version=4.4.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event.
All my F# projects in the solution are 4.0 (4.4.0.0). I double checked.
Why is this happening?
I searched for "4.4.1.0", and discovered that the "obj" folder of the C# project had a .exe.config file that differed from the app.config. It had this extra information that is not in the app.config of the project.
<runtime>
...
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.4.1.0" newVersion="4.4.1.0" />
</dependentAssembly>
</assemblyBinding>
Why is this appended automatically, and why only in this particular C# project?
I tried to copy that section to the app.config of the project, and change it to 4.4.0.0 in both places, but that didn't work. Also tried to use "4.4.1.0" as upper limit of old version, and have "4.4.0.0" as new version, but still didn't work. Same compiler error.
Then I removed that section, and I referenced FSharp.Core 4.4.0.0 in the C# project. That finally got rid of the compile error.
The I ran the program. It crashed with this exception.
Unhandled exception: Could not load file or assembly 'FSharp.Core, Version=4.4.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
I reinserted the section with the redirect, and now the program runs fine.
Just to sum up, I added a reference to FSharp.Core 4.0, and the redirect looks like this
<bindingRedirect oldVersion="0.0.0.0-4.4.1.0" newVersion="4.4.0.0" />
With these modifications, the solution still works as expected also in VS 2015.
I had the same problem, maybe this is helpful for someone:
In my case, the cause was that some of my C# projects with transitive dependencies on FSharp.Core were referencing the runtime's assembly installed on my system directly, instead of using the NuGet package. I.e. the reference didn't have a hint path pointing to the NuGet packages folder, and thus was picking the assembly from C:\Program Files\FSharp\... from the F# SDK. I solved this by removing the reference and reinstalling the FSharp.Core NuGet package.
So this:
<Reference Include="FSharp.Core, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
Turns into:
<Reference Include="FSharp.Core, Version=4.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\FSharp.Core.4.5.2\lib\net45\FSharp.Core.dll</HintPath>
<Private>True</Private>
</Reference>
Check the assembly references of the assembly in the message. For me I had a reference to assembly X which had a reference to Y. Because Y was missing, I got this error. By referencing Y, the error was resolved for me.

TFS Can't Restore NuGet Package

I've got TFS doing some continuous integration builds. Today, it broke for one solution. It seems it can't find AutoMapper. All the other packages can be found just fine.
A couple relevant points:
None of the packages are in source control, we're letting TFS restore them.
We have an internal NuGet feed, but it doesn't seem to be a problem in other solutions, and in this solution we are still getting Entity Framework to restore - just not AutoMapper.
I tried removing and re-adding the NuGet Packages. No luck.
If I use Remote Desktop to connect to the build server and open the project in Visual Studio there, it restores the packages and builds fine.
I can build manually by executing D:\"Program Files"\"Microsoft Team Foundation Server 12.0"\Tools\Nuget.exe restore followed by msbuild MySolutoin.sln
Our TFS server is installed on our D:\ drive.
This is from the TFS Logs:
D:\Program Files\Microsoft Team Foundation Server 12.0\Tools\nuget.exe restore "C:\Builds\1\MyCompany Web\FclQuoteWcfService\src\FclQuoteWcfService.sln" -NonInteractive
Installing 'EntityFramework 6.1.3'.
Installing 'InternalPackage 1.0'.
Successfully installed 'InternalPackage 1.0'.
Successfully installed 'EntityFramework 6.1.3'.
Unable to find version '3.3.1' of package 'AutoMapper'.
C:\Program Files (x86)\MSBuild\12.0\bin\amd64\MSBuild.exe /nologo /noconsolelogger "C:\Builds\1\MyCompany Web\FclQuoteWcfService\src\FclQuoteWcfService.sln" /nr:False /fl /flp:"logfile=C:\Builds\1\MyCompany Web\FclQuoteWcfService\src\FclQuoteWcfService.log;encoding=Unicode;verbosity=normal" /p:SkipInvalidConfigurations=true /m /p:OutDir="C:\Builds\1\MyCompany Web\FclQuoteWcfService\bin\\" /p:VCBuildOverride="C:\Builds\1\MyCompany Web\FclQuoteWcfService\src\FclQuoteWcfService.sln.vsprops" /dl:WorkflowCentralLogger,"D:\Program Files\Microsoft Team Foundation Server 12.0\Tools\Microsoft.TeamFoundation.Build.Server.Logger.dll";"Verbosity=Normal;BuildUri=vstfs:///Build/Build/230;IgnoreDuplicateProjects=False;InformationNodeId=12;TargetsNotLogged=GetNativeManifest,GetCopyToOutputDirectoryItems,GetTargetPath;TFSUrl=http://ctidev2k8:8080/tfs/MyCompany;"*WorkflowForwardingLogger,"D:\Program Files\Microsoft Team Foundation Server 12.0\Tools\Microsoft.TeamFoundation.Build.Server.Logger.dll";"Verbosity=Normal;" /p:BuildId="9aa9f8af-c9b9-4d0a-ba06-7cc959231d8e,vstfs:///Build/Build/230" /p:BuildLabel="FclQuoteWcfService_20150330.2" /p:BuildTimestamp="Mon, 30 Mar 2015 20:40:07 GMT" /p:BuildSourceVersion="LFclQuoteWcfService_20150330.2#$/MyCompany Web" /p:BuildDefinition="FclQuoteWcfService"
Exception Message: MSBuild error 1 has ended this build. You can find more specific information about the cause of this error in above messages. (type BuildProcessTerminateException) Exception Stack Trace: at System.Activities.Statements.Throw.Execute(CodeActivityContext context) at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager) at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)
I've seen this too. It seems to be triggered as soon as NuGet package restore switches to the internal feed. Once it does this is doesn't switch back to the official nuget.org feed and continues to look for the packages on the internal feed.
Ensure both package sources are added to your NuGet.config file. Also ensure both sources are 'active'.
<configuration>
<packageSources>
<add key="nuget.org"
value="https://www.nuget.org/api/v2/" />
<add key="example.com"
value="http://example.com/feed/nuget/" />
</packageSources>
<activePackageSource>
<add key="All"
value="(Aggregate source)" />
</activePackageSource>
</configuration>
See NuGet configuration file documentation.
Matt's answer put me on the right track but we don't use an internal feed so I had to do some more digging. This answer works, at least, for a project created in Visual Studio 2015 and built by TFS 2015.
In Visual Studio, open the NuGet package manager settings (Tools menu > NuGet Package Manager > Package Manager Settings). Choose "Package Sources" from the options list on the left.
Create the nuget.config file at the root of the solution. This should be the same folder location as your ".sln" solution file. Copy the following into the config file:
<configuration>
<packageSources>
</packageSources>
<activePackageSource>
<add key="All"
value="(Aggregate source)" />
</activePackageSource>
</configuration>
Within the <packageSources> tag, create an <add key="" value="" /> entry for each source listed in the "Package Sources" options window. The key is the name of the source as shown above the URL, and the value is the URL itself. Include those listed in both "Available package sources" and "Machine-wide package sources". I did not create an entry for the local filesystem as it wasn't used in this solution. Based on the screenshot above, the complete config file now contains the following:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org"
value="https://api.nuget.org/v3/index.json" />
<add key="Microsoft and .NET"
value="https://www.nuget.org/api/v2/curated-feeds/microsoftdotnet/" />
</packageSources>
<activePackageSource>
<add key="All"
value="(Aggregate source)" />
</activePackageSource>
</configuration>
After committing the nuget.config file to source control, TFS was able to download all the necessary NuGet packages and successfully build the solution.
In addition to Matt's answer, I'd like to highlight the following well-hidden stuff from the NuGet documentation:
NuGet config files are treated in the following priority order
(closest to the folder nuget.exe runs from wins), for example assuming
the solution directory is c:\a\b\c:
c:\a\b\c\.nuget\nuget.config - This file is only used for solution
level packages, and is not supported in nuget 3.0 - 3.4
c:\a\b\c\nuget.config
c:\a\b\nuget.config
c:\a\nuget.config
c:\nuget.config
User specific config file,
%AppData%\NuGet\nuget.config.
Or the user specified file thru option
-ConfigFile.
This could explain some weird behaviour in specific scenario's where a restore does or does not pick up a configured feed, depending on whether youre restoring with nuget 2.x or 3.x
Edit: and I found yet another reason why packages might not be detected:
I have package "A" with version 1.1.1.0 .
Prior 3.4 this command works well:
nuget install A -version 1.1.1.0
With NuGet 3.4 RC I get:
An error occurred while retrieving package metadata for 'A.1.1.1' from
source 'N'. An error occurred while retrieving package metadata for
'A.1.1.1' from source 'N'. Data at the root level is invalid. Line
1, position 1.
...
The client treats 1.1, 1.1.0, 1.01.0 and 1.1.0.0 as the same version
using SemVer rules. The reason non-normalized versions were special
cased in the past is because for v2 http calls the client would first
send the version string exactly as the user specified it

Build on TFS 2013 failed but okay locally

When I checked in the code, TFS 2013 built the solution automatically. It is okay in local VS 2013 but failed in TFS.
Here is the summary.
Summary
FTPProcessor | Any CPU
1 error(s), 56 warning(s)
$/xxxx/NewServiceHost/New-Branch/NewServiceHost/packageRestore.proj - 0 error(s), 0 warning(s)
$/xxxx/NewServiceHost/New-Branch/GenericWindowsServices.sln - 1 error(s), 56 warning(s)
C:\Builds\1\xxxx\FTP Processor (New)\src\.nuget\nuget.targets (71): The task factory "CodeTaskFactory" could not be loaded from the assembly "C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Build.Tasks.v4.0.dll". Could not load file or assembly 'file:///C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Build.Tasks.v4.0.dll' or one of its dependencies. The system cannot find the file specified.
Other Errors
1 error(s)
Exception Message: MSBuild error 1 has ended this build. You can find more specific information about the cause of this error in above messages. (type BuildProcessTerminateException) Exception Stack Trace: at System.Activities.Statements.Throw.Execute(CodeActivityContext context) at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager) at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)
Your TFS 2013 build server is using MSBuild 12.0 where CodeTasksFactory exists in Microsoft.Build.Tasks.v12.0.dll rather than Microsoft.Build.Tasks.v4.0.dll.
Ideally you should be doing the following:
1) Open your NuGet.targets file:
C:\Builds\1\xxxx\FTP Processor (New)\src.nuget\nuget.targets
2) Identify the task referencing the old DLL.
<UsingTask AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll" TaskFactory="CodeTaskFactory" >
...
3) Then future proof it like so:
<UsingTask AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v$(MSBuildToolsVersion).dll" TaskFactory="CodeTaskFactory" >
...
As of VS2013,
you should be running MSBuild from C:\Program Files (x86)\MSBuild\12.0\Bin\
not from C:\Windows\Microsoft.NET\Framework64\v4.0.30319. See
http://blogs.msdn.com/b/visualstudio/archive/2013/07/24/msbuild-is-now-part-of-visual-studio.aspx
source:http://gyorgybalassy.wordpress.com/2013/12/31/msb4175-the-task-factory-codetaskfactory-could-not-be-loaded/
it solved the issue for me.
After much research and trying a bunch of "hacks" I went on to understand the exact mechanics of nuget restore. It turns out, everything has changed since nuget 2.7+ and you're no longer required to include ".nuget" folder and the associated nuget.exe and nuget.target
To fix my build process and use the latest recommended approach, I did the following:
Move nuget.config to be with .sln file same folder path
Delete ".nuget" folder entirely
Delete references to that folder in .sln file
Delete following lines from any .csproj file
--
<RestorePackages>true</RestorePackages>
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
--
This could take some time if your project solution has many files or you work on many projects built with Visual Studio 2013 and before.
The good news is, there's a powershell script that applies the above recursively on any folder:
https://github.com/owen2/AutomaticPackageRestoreMigrationScript/blob/master/migrateToAutomaticPackageRestore.ps1
In short, it reverses "Enable Nuget Package Restore", allowing the
newer package restore method to work.
In Visual Studio 2013, automatic package restore became part of the
IDE (and the TFS build process). This method is more reliable than the
older, msbuild integrated package restore. It does not require you to
have nuget.exe checked in to each solution and does not require any
additional msbuild targets. However, if you have the files related to
the old package restore method in your project, Visual Studio will
skip automatic package restore. (This behavior is likely to change
soon, hopefully it does).
You can use this script to remove nuget.exe, nuget.targets, and all
project and solution references to nuget.targets so you can take
advantage of Automatic Package Restore. It more or less automates the
process described here.
It will recurse through the directory you run the script from and do
it to any solutions that may be in there somewhere. Be careful and
have fun! (not responsible for anything that breaks)
A couple of good links on the subject:
http://blog.davidebbo.com/2014/01/the-right-way-to-restore-nuget-packages.html
http://docs.nuget.org/consume/package-restore/migrating-to-automatic-package-restore
I had a similar issue. We are forced into using the older msbuild that comes with the framework, rather than the v14 version that comes with visual studio 2015 because we build some old Delphi.net code. Our vcxproj files are triggering some automatic code analysis target which has a task that relies on Microsoft.Build.Tasks.v12.0.dll. I was able to override that task by copying and pasting it into the top of the vcxproj and tweaking the path to the dll. The original task can be found in "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\CodeAnalysis\Microsoft.CodeAnalysis.Targets". So, in other words, you might be able to override the problem task in your project.
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- override a task which we can't use with the old msbuild -->
<UsingTask TaskName="SetEnvironmentVariable" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<EnvKey ParameterType="System.String" Required="true" />
<EnvValue ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Using Namespace="System" />
<Code Type="Fragment" Language="cs">
<![CDATA[
try {
Environment.SetEnvironmentVariable(EnvKey, EnvValue, System.EnvironmentVariableTarget.Process);
}
catch {
}
]]>
</Code>
</Task>
</UsingTask>

Missing Microsoft.Build.Tasks.v4.0.dll on visual studio online tfs build

I am trying to build my project with visual studio online.
I am getting the following error.
C:\a\src\.nuget\nuget.targets (71): The task factory "CodeTaskFactory" could not be loaded from the assembly "C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Build.Tasks.v4.0.dll". Could not load file or assembly 'file:///C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Build.Tasks.v4.0.dll' or one of its dependencies. The system cannot find the file specified.
This is coming from the nuget.targets file in my solution.
<UsingTask TaskName="SetEnvironmentVariable" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<EnvKey ParameterType="System.String" Required="true" />
<EnvValue ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Using Namespace="System" />
<Code Type="Fragment" Language="cs">
<![CDATA[
try {
Environment.SetEnvironmentVariable(EnvKey, EnvValue, System.EnvironmentVariableTarget.Process);
}
catch {
}
]]>
</Code>
</Task>
</UsingTask>
I have updated nuget.exe to latest and have not changed anything in nuget.targets.
The problem was that some of the class libraries in the solution had the default value :
ToolsVersion="12.0"
changing that to
ToolsVersion="4.0"
made it work on TFS online
I ran into this after upgrading a project to .NET 4.5.2. Seems to be a conflict between the .NET 4.5 point releases and the old way to do NuGet package restore (MSBuild-Integrated package restore vs Automatic Package Restore).
I was able to solve the issue by migrating NuGet to the new way of doing package restore: http://docs.nuget.org/consume/package-restore/migrating-to-automatic-package-restore
More info: http://blog.davidebbo.com/2014/01/the-right-way-to-restore-nuget-packages.html

Resources