VS 2015 Toolset may be unknown or missing - c#

I try to publish project to my file directory.
I take a this message. But do not shown any error. Error list is empyty.
2> Building with tools version "14.0".
2> Project file contains ToolsVersion="12.0". This toolset may be
unknown or missing, in which case you may be able to resolve this by
installing the appropriate version of MSBuild, or the build may have
been forced to a particular ToolsVersion for policy reasons. Treating
the project as if it had ToolsVersion="14.0". For more information,
please see http://go.microsoft.com/fwlink/?LinkId=293424. 2> Target
"ValidateMSBuildToolsVersion" skipped. Previously built
unsuccessfully. 2>Done building project "project_name.csproj" – FAILED. 2>
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Publish: 0 succeeded, 1 failed, 0 skipped ==========

VS 2015 Toolset may be unknown or missing
According to the error message "Project file contains ToolsVersion="12.0". ", it shows that your project was upgraded from Visual Studio 2013. So when you publish it with Visual Studio 2015, you may get this error "This toolset may be unknown or missing..."
To resolve this issue, you can try to update your project file: Right your project->Unload project->Edit Yourprojectname.csproj->change the ToolsVersion="12.0" to ToolsVersion="14.0" in the second line.
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
If you are using MSBuild command line build your project, you can can override the ToolsVersion Settings of Projects and Solutions by using command prompt:
msbuild.exe someproj.proj /tv:14.0

Why don't you try changing the version of the "Microsoft.Net.Compilers" from from v2.6.1 to v2.4.0 as per explained here

Related

Why is MSBuild looking at incorrect path?

I have been trying to build a .NET project with visual studio 2017 Community on my local.
The build works fine when done using Publish option but throws below error when trying using msbuild
C:\Users\ajay3\source\repos\Triyo.API\TriyoCore.API>msbuild
Microsoft (R) Build Engine version 4.8.4084.0
[Microsoft .NET Framework, version 4.0.30319.42000]
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 2021-06-28 3:55:47 PM.
Project "C:\Users\ajay3\source\repos\Triyo.API\TriyoCore.API\TriyoCore.API.csproj" on node 1 (default targets).
C:\Users\ajay3\source\repos\Triyo.API\TriyoCore.API\TriyoCore.API.csproj(281,3): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualSt
udio\**v11.0**\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
Done Building Project "C:\Users\ajay3\source\repos\Triyo.API\TriyoCore.API\TriyoCore.API.csproj" (default targets) -- FAILED.
Build FAILED.
"C:\Users\ajay3\source\repos\Triyo.API\TriyoCore.API\TriyoCore.API.csproj" (default target) (1) ->
C:\Users\ajay3\source\repos\Triyo.API\TriyoCore.API\TriyoCore.API.csproj(281,3): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\Visual
Studio\**v11.0**\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on
disk.
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.08
I have gone through various similar articles on Stackoverflow and various other sites but none of them help.
Where it is pulling v11.0 from? I don't have that value in my csproj file.
Are you using correct version of MSBuild?
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
C:\Windows\Microsoft.NET\Framework\v2.0.50727\MSBuild.exe
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\MSBuild.exe
The path to MSBuild could be different depending on your pc
If Yes check the following example
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe C:\Users\ajay3\source\repos\Triyo.API\TriyoCore.API\TriyoCore.API.csproj /t:Clean
For more information run the following command:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /?
You can also use this link
I cleaned up my system and reinstalled msbuild and it works fine now.

Error Metadata file dll could not be found CSC when publishing

I have a Visual studio solution with several projects in it, specifically a DotNet5 asp.net app, that has several netstandard 2.0 references on it. it builds and runs fine in the debugger but continuously throws the metadata errors. It keeps specifically referencing its looking for a net5 folder in the netstandard2 project. I cannot find where its getting this from, the problematic one used to be a multitargeted project against framework 4.7, 4.8, and net5.0, but i got annoyed with the multiple dll's and just migrated it to standard2.0 and had no issues till i want to publish it.
I've tried what a few other questions referenced, cleaning, rebuilding, remove and re add references to other projects, deleted the obj and bin folders out of the solution, the removing the sou file, tried VS 2019 (16.9.0 preview 2) preview vs 2019 (16.8.3) release, different computer (pulled back down from a lan git repository) and got the same error.... also tried searching the entire solution for references to net5.0 and didn't find it outside of the expected locations like the csproj for the asp.net project and its respective pubxml. And just for fun, I temporarily retargeted the library project back to net5.0 and it still threw the same error even when the exact file and path listed did exist.
Using enters for the error below for the different columns in the error message, and removed the "sensitive" info. There is no error code provided by Visual Studio. Anyone else got any more ideas on what to try?
Error
Metadata file 'C:\Users\UserName\source\repos\Solution\Project 2\bin\Release\net5.0\ref\Project 2.dll' could not be found.
Project 1
CSC
0
Edit: adding a couple other sections of the error messages:
1/2/2021 7:38:55 PM
System.AggregateException: One or more errors occurred. ---> Microsoft.WebTools.Shared.Exceptions.WebToolsException: Build failed. Check the Output window for more details.
--- End of inner exception stack trace ---
---> (Inner Exception #0) Microsoft.WebTools.Shared.Exceptions.WebToolsException: Build failed. Check the Output window for more details.<---
Microsoft.WebTools.Shared.Exceptions.WebToolsException: Build failed. Check the Output window for more details.
===================
And the end of the output window since full thing is a bit too long. still can't figure out where its getting the net5.0 for the one project reference
/reference:C:\Users\UserName\.nuget\packages\system.xml.xpath.xmldocument\4.0.1\ref\netstandard1.3\System.Xml.XPath.XmlDocument.dll /reference:C:\Users\UserName\.nuget\packages\mysql.data\8.0.22\lib\net5.0\Ubiety.Dns.Core.dll /reference:"C:\Users\UserName\source\repos\CheckNotes\Project 3\bin\Release\netstandard2.0\Project 3.dll" /reference:"C:\Users\UserName\source\repos\CheckNotes\Project 2\bin\Release\net5.0\ref\Project 2.dll" /reference:C:\Users\UserName\source\repos\CheckNotes\Project 4\bin\Release\netstandard2.0\Project 4.dll /reference:"C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0\ref\net5.0\WindowsBase.dll" /reference:C:\Users\UserName\.nuget\packages\mysql.data\8.0.22\lib\net5.0\Zstandard.Net.dll /debug+ /debug:portable /filealign:512 /optimize+ /out:"obj\Release\net5.0\CheckNotes Web - Core.dll" /refout:"obj\Release\net5.0\ref\CheckNotes Web - Core.dll" /target:exe /warnaserror- /utf8output /deterministic+ /langversion:9.0 /analyzerconfig:"obj\Release\net5.0\CheckNotes Web - Core.GeneratedMSBuildEditorConfig.editorconfig" /analyzerconfig:"C:\Program Files\dotnet\sdk\5.0.200-preview.20601.7\Sdks\Microsoft.NET.Sdk\analyzers\build\config\AnalysisLevel_5_Default.editorconfig" /analyzer:"C:\Program Files\dotnet\sdk\5.0.200-preview.20601.7\Sdks\Microsoft.NET.Sdk.Web\analyzers\cs\Microsoft.AspNetCore.Analyzers.dll" /analyzer:"C:\Program Files\dotnet\sdk\5.0.200-preview.20601.7\Sdks\Microsoft.NET.Sdk.Web\analyzers\cs\Microsoft.AspNetCore.Mvc.Analyzers.dll" /analyzer:"C:\Program Files\dotnet\sdk\5.0.200-preview.20601.7\Sdks\Microsoft.NET.Sdk.Web\analyzers\cs\Microsoft.AspNetCore.Components.Analyzers.dll" /analyzer:"C:\Program Files\dotnet\sdk\5.0.200-preview.20601.7\Sdks\Microsoft.NET.Sdk\targets\..\analyzers\Microsoft.CodeAnalysis.CSharp.NetAnalyzers.dll" /analyzer:"C:\Program Files\dotnet\sdk\5.0.200-preview.20601.7\Sdks\Microsoft.NET.Sdk\targets\..\analyzers\Microsoft.CodeAnalysis.NetAnalyzers.dll" Controllers\AssemblyController.cs Controllers\CheckNotesController.cs Controllers\ContactsController.cs Controllers\CustomerController.cs Controllers\HomeController.cs Controllers\ImageController.cs Controllers\OperatorPagesController.cs Controllers\PalletsController.cs Controllers\SharedController.cs Controllers\StatisticsController.cs Models\ControllerClass\ctrlrAssembly.cs Models\ControllerClass\CtrlrCheckNotes.cs Models\ControllerClass\ctrlrContacts.cs Models\ControllerClass\CtrlrCustomer.cs Models\ControllerClass\CtrlrOperatorPages.cs Models\ControllerClass\CtrlrPallet.cs Models\ControllerClass\ctrlrStats.cs Models\DataClass\AppSettings.cs Models\ErrorViewModel.cs Models\renderAction.cs Program.cs Startup.cs "obj\Release\net5.0\.NETCoreApp,Version=v5.0.AssemblyAttributes.cs" "obj\Release\net5.0\CheckNotes Web - Core.AssemblyInfo.cs" "obj\Release\net5.0\CheckNotes Web - Core.RazorAssemblyInfo.cs" /warnaserror+:NU1605
CSC(0,0): Error CS0006: Metadata file 'C:\Users\UserName\source\repos\CheckNotes\Project 2\bin\Release\net5.0\ref\Project 2.dll' could not be found
10>Build failed. Check the Output window for more details.
========== Build: 9 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Publish: 0 succeeded, 1 failed, 0 skipped ==========
Got it to publish but I am so confused....something to do with the publish profile. If i delete that and generate a new one, works fine. as soon as i edit it using the GUI, broken....generate it again. So far seems ok to edit it manually but TBD. not sure if the "fix" will survive restarting Visual studio or not.
Edit - Scratch that, found the difference.
Remove the following line in Properties/FolderProfile.pubxml and it's fine.
<TargetFramework>net5.0</TargetFramework>

Out of memory error when compiling UWP app in release mode with .Net native

I have a solution where my main project is a uwp app, and two other projects referenced by the app :
UWP App ---> references 2.
Universal Class library ----> references 3.
PCL Library
2 --> uses EF7 and SQLight.
3 --> uses PCLCrypto
Now, everything works just fine and excellent when I'm on Debug mode x86 targeting local machine.
I want to compile the solution in release mode using .Net native tool chain, here's my config :
When I launch the compilation, it takes a remarkably long time, and too much memory is consumed by the .Net native tools :
After some time, everything stops with 2 errors on visual studio :
Here's what the output window says :
1>------ Build started: Project: ServerCommunication, Configuration:
Release Any CPU ------ 1> ServerCommunication ->
C:\Users\aymen\Documents\Visual Studio
2015\Projects\Applinova\Liberte\ServerCommunication\bin\Release\ServerCommunication.dll
2>------ Build started: Project: NewspaperDataLayer, Configuration:
Release x86 ------ 2>C:\Users\aymen\Documents\Visual Studio
2015\Projects\Applinova\Liberte\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets(225,5):
warning : All projects referencing ServerCommunication.csproj must
install nuget package Microsoft.Bcl.Build. For more information, see
http://go.microsoft.com/fwlink/?LinkID=317569. 2> NewspaperDataLayer
-> C:\Users\aymen\Documents\Visual Studio 2015\Projects\Applinova\Liberte\NewspaperDataLayer\bin\x86\Release\NewspaperDataLayer.dll
3>------ Build started: Project: Liberte, Configuration: Release x86
--some warnings here that I just skipped
3> Starting .NET Native compilation 3> Processing application code
3>C:\Users\aymen\Documents\Visual Studio
2015\Projects\Applinova\Liberte\Liberte\Resources.System.Linq.Expressions.rd.xml(35):
warning : Method 'CreateLambda' within
'System.Linq.Expressions.Expression' could not be found.
3>C:\Users\aymen\Documents\Visual Studio
2015\Projects\Applinova\Liberte\Liberte\Resources.System.Linq.Expressions.rd.xml(91):
warning : Method 'ParameterIsAssignable' within
'System.Linq.Expressions.Expression' could not be found. 3> Computing
application closure and generating interop code 3> Generating
serialization code 3> Compiling interop code 3> Cleaning up
unreferenced code 3> Generating native code 3>STARTPROCESSTASK :
error : Out of Memory 3>C:\Program Files
(x86)\MSBuild\Microsoft.NetNative\x86\ilc\IlcInternals.targets(1129,5):
error : ILT0005: 'C:\Program Files
(x86)\MSBuild\Microsoft.NetNative\x86\ilc\Tools\nutc_driver.exe
#"C:\Users\aymen\Documents\Visual Studio
2015\Projects\Applinova\Liberte\Liberte\obj\x86\Release\ilc\intermediate\MDIL\Liberte.rsp"'
returned exit code 1
========== Build: 2 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Deploy: 0 succeeded, 0 failed, 0 skipped ==========
What would possibly be wrong with this please ??
I had the same problem (I am also using EF7 and other libraries) but I solved using Visual Studio 15 preview (it is not visual studio 2015 update 2, which I didn't try). They improved the .NET native tools so now you should not have any problem, even if using a lot of third party library.
UPDATE
I have solved all my issues after i have installed visual studio 2015 update 3 and switched from EF7 to EF core also available via nuget
I have been struggled past few days around trying to fix this problem, but currently there is no easy solution for it.
There is a closed Issue on EF7 github, more info here (https://github.com/aspnet/EntityFramework/issues/4387) where they suggest as solution update EF7 to v1.0.0-rc2-16898.
I didn't manage how to update and as it still a nightly version, my final solution ("fast" workaround) was change my entire DB to sqlite-pcl (https://visualstudiogallery.msdn.microsoft.com/4913e7d5-96c9-4dde-a1a1-69820d615936).
If you aren't in a rush to lunch your application, you can always wait until final version of RC2 it should be done during April.

Building C# .NET in command line gives error: Package 'Code Analysis Package' failed to load

I am compile a sample C# .NET project using build.cmd file. The content of the build.cmd is as bellow.
build.cmd
#echo off
setlocal
set devenv="c:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.com"
del *.log >nul
%devenv% WindowsFormsApplication3.sln /rebuild "Release" /out WindowsFormsApplication3.log
if ERRORLEVEL 1 GOTO failed
findstr /C:"========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========" WindowsFormsApplication3.log >nul
if ERRORLEVEL 1 GOTO failed
echo *** BUILD SUCCESSFUL ***
pause
goto :EOF
:failed
echo.
echo.
echo *** BUILD FAILED ***
pause
Project compiles properly. But when i opened the log file it hassome error
WindowsFormsApplication3.log
1>------ Rebuild All started: Project: WindowsFormsApplication3, Configuration: Release Any CPU ------
Package 'Code Analysis Package' failed to load.
1> WindowsFormsApplication3 -> E:\Bin\junk\WindowsFormsApplication3\WindowsFormsApplication3\bin\Release\WindowsFormsApplication3.exe
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
I don't why i am getting this error (Package 'Code Analysis Package' failed to load) in log file.
I searched online but did not get any help.
how to solve this problem?
Note: WindowsFormsApplication3 is a sample project. i Opened VS2015 and New Project -> Visual C# -> Windows Form Application. I did not change any thing in the project.
Give Microsoft a chance to analyze and fix the problem.
I created a connect issue because the problem occurs on two PCs that both have vanilla VS 2015 installations.
https://connect.microsoft.com/VisualStudio/feedback/details/2423616/package-code-analysis-package-failed-to-load
Within the next few weeks, a guy from Microsoft will probably comment on that. You can followup there.

Monogame Content Pipeline has stopped working

The other day I started up my monogame project and started it up to do a quick play test. It wouldn't work. I was getting 2 errors.
Error 1 The command "SETX MONOGAME_PLATFORM "PSM" > NUL" exited with code 9009. GameName1
Error 2 Metadata file 'C:\Users\Sean\Desktop\Prog\Learning\3D Learning\GameName1\GameName1\bin\PSM\IgnoreMe.dll' could not be found C:\Users\Sean\Desktop\Prog\Learning\3D Learning\3D Learning\CSC 3D Learning
And here is the output from the build.
1>------ Build started: Project: Learnplscon, Configuration: PSM Any CPU ------
1> MonoGame Platform PSM
1> 'SETX' is not recognized as an internal or external command,
1> operable program or batch file.
1>C:\Program Files (x86)\MSBuild\MonoGame\v3.0\MonoGame.ContentPipeline.targets(22,7): error MSB3073: The command "SETX MONOGAME_PLATFORM "PSM" > NUL" exited with code 9009.
2>------ Build started: Project: learnpls, Configuration: Debug x86 ------
2>CSC : error CS0006: Metadata file 'C:\Users\Sean\Desktop\Prog\Learning\learnpls\Learnplscon\Learnplscon\bin\PSM\IgnoreMe.dll' could not be found
========== Build: 0 succeeded, 2 failed, 0 up-to-date, 0 skipped ==========
But Building from last successful build works.
I did not change anything. And any new project I make gets the same problem.
The problem only happens when I add a reference to my content project.
(Referenced project this way: monogame-managing-content )
I made a new project, ran it, everything worked fine. Created a mono game content project, ran it and everything worked fine. Then I added the reference and got the errors. And when I remove the reference Error 2 goes away but error 1 is still there, but the project will run fine.
I have tried reinstalling xna, and monogame. Also tried to reinstall visual studios. I spent all night trying to find an answer online but came up with nothing.
I am using the most recent version of XNA and Monogame 3.2, and I am using windows 8.1.
In case you're still having this problem, or someone else finds the question (like I did trying to solve this a little while ago): for me, the problem was that my windows/system32 directory wasn't in my 'path' environment variable. That's where the setx.exe program resides, and the XNA content project seems to assume that it can call setx without qualifying the path.
Note: Visual Studio seems to need to be restarted after you've added your /system32 directory to the path.

Categories