After installing this version, nothing that touches F# will build, everything throws the same exception:
error FS0193: Could not load file or assembly System.Buffers, Version=4.0.3.0, blablabla..
Apparently it's nothing to do with what I'm building. Even trying to execute let x = 3 in fsi.exe has the same problem.
Anyone else had this problem?
Yes, this is a known problem, see https://github.com/dotnet/fsharp/issues/9295.
While the next fix isn't out yet, you can resolve it by manually copying the missing assemblies. The exact list of missing assemblies is mentioned in this comment. The cause was explained by Kevin Ransom to be that the Setup for MSBuild didn't get the new dependencies for fsc.exe.
Note that FSI from within Visual Studio shouldn't have this issue, nor should building from within Visual Studio 2019. The way I understand it, only the MSBuild Tools are affected.
For posterity, in case the links go dead, the workaround in the Github issue is to just copy the dlls over:
copy "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\IDE\PublicAssemblies\*.dll" "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\IDE\CommonExtensions\Microsoft\FSharp"
Edit: the source path given above may not always be correct, depending on what versions of VS you've installed. Alternatively, try:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\PublicAssemblies
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\PublicAssemblies
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\PublicAssemblies
C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\Common7\IDE\PublicAssemblies
If you only want to copy the minimal set that's needed, just copy only these files, that's the diff set:
System.Buffers.dll
System.Memory.dll
System.Numerics.Vectors.dll
System.Reflection.Metadata.dll
System.Resources.Extensions.dll
System.Runtime.CompilerServices.Unsafe.dll
System.Threading.Tasks.Dataflow.dll
Related
I am creating a generic script to deploy on the build server to build our project using VS 2019. The location of nmake in VS 2019 is at: C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\bin. The inclusion of numbers like 14.29.30133 doesn't allow the script to be very generic.
In the earlier generations of VS, nmake paths were like: C:\Program Files\Microsoft Visual Studio 10.0\Vc\bin or C:\Program Files (x86)\Microsoft Visual Studio 11.0\Vc\bin
Maybe I installed MSVC incorrectly? Any help is appreciated. TIA.
You installed MSVC correctly, and yes, this can cause some headaches, because the version number in the folder name changes with every new minor release of VS 2019.
To resolve this, use this command line snippet for getting the path to the latest installed nmake.exe into the variable %NMAKE%:
set VSPATH=C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional
for /f %%i in ('dir "%VSPATH%\VC\Tools\MSVC" /b') do set VCTOOLSVERSION=%%i
set NMAKE="%VSPATH%\VC\Tools\MSVC\%VCTOOLSVERSION%\bin\HostX86\x86\nmake.exe"
This works for all intermediate versions of Visual Studio 2019 I tested it with.
I don't recall the previous version I had (it could have been 16.8.1), but updating just now to 16.8.4 results in none of my solution projects being able to load. Here's the output window for one of my solutions:
F:\Users\username\Documents\Visual Studio Projects\FitnessManagerCore\FitnessManagerCore\FitnessManagerCore.csproj : error : The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Roslyn\Microsoft.CSharp.Core.targets" was not found. Confirm that the expression in the Import declaration "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Roslyn\Microsoft.CSharp.Core.targets" is correct, and that the file exists on disk. C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.CSharp.CurrentVersion.targets
F:\Users\username\Documents\Visual Studio Projects\GeneralUtilities\GeneralUtilities\GeneralUtilities.csproj : error : The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Roslyn\Microsoft.CSharp.Core.targets" was not found. Confirm that the expression in the Import declaration "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Roslyn\Microsoft.CSharp.Core.targets" is correct, and that the file exists on disk. C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.CSharp.CurrentVersion.targets
F:\Users\username\Documents\Visual Studio Projects\FitnessManagerCore\FitnessManagerConsole\FitnessManagerConsole.csproj : error : The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Roslyn\Microsoft.CSharp.Core.targets" was not found. Confirm that the expression in the Import declaration "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Roslyn\Microsoft.CSharp.Core.targets" is correct, and that the file exists on disk. C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.CSharp.CurrentVersion.targets
VS advised to try to reload the projects manually. When I attempt this, I get the following error message:
It seems Microsoft has no means to roll back a previous installation. I do not have a restore point. I do not want to uninstall/reinstall.
Edit:
I just tried creating a new solution to see what would happen if I tried to load one of my existing projects. When creating a console app w/ .NET Core, I get this:
Update:
This latest VS 2019 simply does not want to work on my machine in any capacity. I uninstalled VS 2019, rebooted, and attempted to reinstall. The installation stops midway with the below error message. When I click "Report this problem", it opens a Microsoft web page to report the issue, but says "Disconnected from Visual Studio". Since I can't roll back to a previous version according to what I'm reading, I guess I just can't use VS 2019 anymore.
You could check in your csporj file if you have:
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
You would need to change MSBuildToolsPath to MSBuildBinPath, like this:
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
When you create a project in Visual Studio 2008, $(MSBuildToolsPath) is added by default to your csproj file as the path to Microsoft.Build.Engine v3.5.
Be sure to change it to $(MSBuildBinPath) which is the path to Microsoft.Build.Engine v2.0.
(more info here)
What is the location of vcvarsall.bat file for Visual Studio 2019 (Preview and future release as well)?
Seems it is different from VS 2017 "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat"
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat"
As it turned out the path is very similar, just without "Community" part:
For VS2019:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Auxiliary\Build\vcvarsall.bat
For VS2022 since the toolchain now is 64-bit:
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat
If after installing the "Build Tools for Visual Studio 2019" and doing all that was recommended in the other answers, you still can't find the the file in the location mentioned (no Build folder inside Auxiliary) make sure you
Install "Desktop Development With C++ Workload"
because vcvarsall.bat is part of C++ workload.
(In VS, go Tools menu -> Get Tools and Features -> Install the Desktop Development With C++ workload)
You need to install the "Build Tools for Visual Studio 2019" which can be found here.
See the explanation:
You can build C and C++ applications on the command line by using tools that are included in Visual Studio. The Microsoft C++ (MSVC) compiler toolset is also downloadable as a standalone package from the Visual Studio downloads page. It's part of the Build Tools for Visual Studio package. You can choose to download only the tools you need for C++ development.
If you are using it in the pre-build event, you can execute the vcvars32.bat to set the environment variable VCINSTALLDIR and get rid of the Visual Studio version:
call "$(DevEnvDir)....\VC\Auxiliary\Build\vcvars32.bat"
Then
"%VCINSTALLDIR%\Auxiliary\Build\vcvarsall.bat"
Note:
-In my tests, the variable VCINSTALLDIR has value only after executing the vcvars32.bat
-As Wei Yang said you need to install "Build Tools for Visual Studio 2019", it can be installed using Visual Studio Installer.
I felt free to add a possible solution.
1.) Open the Developer Command Prompt for your wanted VS if you have more than one installed. BTW this lets you work with TFS tool tf if you need it.
2.) Add in your make script the following code at the concerning location:
for /f "delims=" %%d in ('dir /s /b %VSINSTALLDIR%\vcvarsall.bat"') do #set myVCVARSALL=%%d
if not defined myVCVARSALL exit 1
call %myVCVARSALL%
Hope that helps to find this file for the wanted VS version. It results in different files for different installations.
I needed to install and build some older build tools for windows. So, I had to set the location.
The location is C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build
If you haven't installed the "Build Tools for Visual Studio 2019", you can do so from https://visualstudio.microsoft.com/downloads/.
Once this is done, the correct path for running vcvarsall.bat is;
"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat"
For VS 2019 Professional, it is "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvarsall.bat"
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat this is the location.
I've installed TFS (version 15.112.26307.0) on windows server 2012 R2. all team members use VS2017 to coding. I've created an agent (I've tried versions vsts-agent-win7-x64-2.112.0, 2.117.0 ,2.140.0)and set it's MSBuild version to MSBuild15.0 :
MSBuild15.0 has already installed on the server :
But when we use c# 7 features in our code(like "int out x") building code via TFS raise error as below (it use MSBuild14.0 to build our code, why?)
My agent capabalities is not correct :
Use the Visual Studio Build task. It allows you to specify the Visual Studio version used to run builds.
Seems the capabilities cannot be detected by the agent. If you have installed the VS 2017 on the build agent server, then you can try to restart the agent service to check if that works.
If that still not work, you could try below things:
Add the capabilities manually.
The path of them are(Enterprise version for example):
VisualStudio_15.0 C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\
VisualStudio_IDE_15.0 C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\
MSBuild_15.0 C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\
MSBuild_15.0_x64 C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\amd64\
VSTest C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common\IDE\CommonExtensions\Microsoft\TestWindow
Specify the path to Msbuild 15.0:
I am trying to build UWP app (targeting 16299) from command line from Jenkins setup.
The system has only VS build tools 2017.
used this command to build
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\msbuild.exe" /t:Rebuild /p:Configuration=Release;AppxBundle=Always;AppxBundlePlatforms="x86\x64\ARM" /p:BuildAppxUploadPackageForUap=true SOLUTION_FILE.sln
error MSB4226: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\WindowsXaml\v15.0\Microsoft.Windows.UI.Xaml.CSharp.targets" was not found. Also, tried to find "Microsoft\WindowsXaml\v15.0\Microsoft.Windows.UI.Xaml.CSharp.targets" in the fallback search path(s) for $(MSBuildExtensionsPath) - "C:\Program Files (x86)\MSBuild" . These search paths are defined in "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe.Config". Confirm that the path in the declaration is correct, and that the file exists on disk in one of the search paths.
Another issue found is nuget is not restoring any package, so updated nuget to 4.4.1 then I got the error
MSBuild auto-detection: using msbuild version '15.5.180.51428' from 'C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\bin'.
Nothing to do. None of the projects in this solution specify any packages for NuGet to restore.
same issue with nuget 4.6.0 also
I tried by adding following in project file
<PropertyGroup>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle> </PropertyGroup>
same issue with msbuild and nuget, anyone succeed in building UWP in Jenkins?
Update 05-01-2015
Followed instruction according to answer.
Copied NuGet folder
Copied the "WindowsXaml" folder.
Used MSbuild restore instead of Nuget restore to fix msbuild trying to find packages in "C:\WINDOWS\system32\config\systemprofile.nuget\packages\"
With all these changes no more issues in build,
But the appx bundle is not present. may be individual appx for x86/x64/ARM has to be created and then some kind of merging i s required.
so need further investigations
From the directory path that you have for MSBuild, I see that you may have installed MSBuildTools installer instead of the community, professional,... editions.
I tried that before and found that it's incomplete and doesn't have all dependencies for building Uwp tools, take a look at some of the comments here about the issues.
First Workaround: You can install Uwp Workload from VS Community or Professional as it has all dependencies, till Microsoft fix the issues in BuildTools installer.
Bonus: if you want to run the installer from command line, you can compose command line like that:
vs_installer.exe --installPath "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools" ^
--add Microsoft.VisualStudio.Workload.Universal ^
--add Microsoft.VisualStudio.Component.Windows10SDK.14393 ^
--add Microsoft.Component.MSBuild ^
--passive --wait --norestart
The longer workaround, I managed to install other dependencies but I believe it's kind of hassle if you are automating this installation, snippets from this article
Copy the Sdks folder from a machine that has VS2017 installed at:
c:\Program Files(x86)\Visual Studio\2017\Professional\Build MSBuild\Sdks
to your build machine at:
c:\Program Files(x86)\Visual Studio\2017\Build Tools\MSBuild\Sdks
And for the nuggets issue:
Copying the NuGet import files will do the tr Again, from a machine
with VS2017, copy the following folder: C:\Program Files
(x86)\Microsoft Visual
Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\NuGet
to your build machine at: C:\Program Files (x86)\Microsoft Visual
Studio\2017\BuildTools\Common7\IDE\CommonExtensions\Microsoft\NuGet
Note: If you come by this later and found that Microsoft fixed the issues related to Uwp in MSBuildTools installer, please leave a comment about it in this answer to update it.