MSB4018: The "GetFrameworkPath" task failed unexpectedly [duplicate] - c#

I've upgraded my TDS to 5.5 and now I get the following error when opening a solution containing a TDS project with Visual Studio:
TDS failed to change configurations with the error 'Build of GetFrameworkPaths failed.'.
Please see the output window for more details.

This is a known issue not yet fixed by Hedgehog. They do provide a workaround:
http://www.hhogdev.com/blog/2016/may/common-problem-after-tds-5,-d-,5-upgrade.aspx
To save some time you can just delete the
C:\Program Files (x86)\MSBuild\HedgehogDevelopment\SitecoreProject\v9.0\HedgehogDevelopment.SitecoreProject.targets
file and run the TDS installer and choose repair instead of uninstalling and reinstalling TDS as Hedgehog recommends.

This error can also appear when running into code / build issues. I saw this error when there was a line ending issue which resulted in a syntax error in my code generation output (eg. Models.cs).
Try these:
Restart Visual Studio and/or your PC.
Unload and reload the TDS project(s) with dependencies.
Restore NuGet packages.
Check your TDS logs / outputs as there may be a more specific error that precedes this one.
Inspect your code for any syntax errors / line ending issues.
Inspect your code for any rule / code quality violations.
Verify that your other projects can build successfully.

Related

Publishing two core projects in TFS in one solution causes "...\System.EnterpriseServices.Wrapper.dll' could not be found" error

I have a dotNet Core solution containing three projects - one common code, one "read-only" web service and one "admin" web service (which has all the POST, PUT and DELETE routes). The solution builds just fine locally and works. I want to build both projects and run both their publish operations to generate the output artifacts as part of the TFS Gated Check-In.
I have a build definition in TFS (2017) which includes a dotnet build task in which I specified the two project file paths and which has the following parameters...
/p:AssemblyVersion=$(Build.BuildNumber)
/p:Version=$(Build.BuildNumber) /p:DeployOnBuild=True
/p:PublishProfile=Dev.pubxml /p:AllowUntrustedCertificate=True
/p:Configuration=$(BuildConfiguration)
When the build runs it has no problem with the first project which builds just fine and correctly publishes, but when it then attempts to build the second project it comes up with the error...
Copyright (C) Microsoft Corporation. All rights reserved.
Restoring packages for e:\ci\builds\173\s\JMO.WebAPI\develop\JMOAdmin.WebAPI\JMOAdmin.WebAPI.csproj...
Restore completed in 23.62 ms for e:\ci\builds\173\s\JMO.WebAPI\develop\JMO.DAL\JMO.DAL.csproj.
Restore completed in 78.55 ms for e:\ci\builds\173\s\JMO.WebAPI\develop\JMO.WebAPI\JMO.WebAPI.csproj.
Restore completed in 34.6 ms for e:\ci\builds\173\s\JMO.WebAPI\develop\JMO.WebAPI\JMO.WebAPI.csproj.
Generating MSBuild file e:\ci\builds\173\s\JMO.WebAPI\develop\JMOAdmin.WebAPI\obj\JMOAdmin.WebAPI.csproj.nuget.g.props.
Restore completed in 1.3 sec for e:\ci\builds\173\s\JMO.WebAPI\develop\JMOAdmin.WebAPI\JMOAdmin.WebAPI.csproj.
JMO.DAL -> e:\ci\builds\173\s\JMO.WebAPI\develop\JMO.DAL\bin\dev\netcoreapp2.1\JMO.DAL.dll
CSC : error CS0006: Metadata file 'e:\ci\builds\173\s\JMO.WebAPI\develop\JMO.WebAPI\publish\System.EnterpriseServices.Wrapper.dll' could not be found [e:\ci\builds\173\s\JMO.WebAPI\develop\JMO.WebAPI\JMO.WebAPI.csproj]
Build FAILED.
CSC : error CS0006: Metadata file 'e:\ci\builds\173\s\JMO.WebAPI\develop\JMO.WebAPI\publish\System.EnterpriseServices.Wrapper.dll' could not be found [e:\ci\builds\173\s\JMO.WebAPI\develop\JMO.WebAPI\JMO.WebAPI.csproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:03.71
Error: C:\Program Files\dotnet\dotnet.exe failed with return code: 1
Dotnet command failed with non-zero exit code on the following projects : e:\ci\builds\173\s\JMO.WebAPI\develop\JMOAdmin.WebAPI\JMOAdmin.WebAPI.csproj
Here's the rub though, if I swap the order of the projects in the task it is still the second project that fails to build. What is more, if I add a second dotnet build task so there is one for each project it still does the same - the second build fails with the same error, irrespective of which actual project builds first. The same applies if I use a wildcard for the project file names.
The other thing to note is that the file specified in the error (System.EnterpriseServices.Wrapper.dll) is not to be found in either build's output path anyway, whether the build succeeds or not!
The only way I have found so far to get a successful build of both projects is to use the MultiConfiguration option with a Pass1,Pass2 value and enable/disable the build tasks so that it takes two entire passes at the process, once for the "read-only" WS and one for the admin WS. I'm guessing that something is getting stuck in memory during the first project build process and it's tripping up the second but I can't prove it so far.
My problem with this solution is that this only works on the develop branch, on the release branch I need to use the multi-configuration option for the intended purpose - the various target environments (test, uat, prod).
Short of installing a TFS extension to chain builds (not ideal but viable), can anyone suggest why I'm getting this behaviour and, more importantly, suggest a better solution.
Cheers.

TeamCity with SonarQube for Code Analysis build fails

Very common problem for many users, that SonarQube Code Analysis fails with an error:
[10:06:05]No ProjectInfo.xml files were found. Possible causes:
[10:06:05]1. The project has not been built - the end step was called right
after the begin step, without a build step in between
[10:06:05]2. An unsupported version of MSBuild has been used to build the
project. Currently MSBuild 12.0 upwards are supported
[10:06:05]3. The build step has been launched from a different working folder
[10:06:05]Post-processing failed. Exit code: 1
[10:06:05]Process exited with code 1
A lot of references say that fix is to use full path for MSBuild.exe, but yes, I use full path, but also I use MSBuild 15.0 version with newest C# version, older MSBuild just fails for new C# features in code.
However I can't get rid of this error and I have no idea what can be done about it, so maybe any of you guys have already met this problem and could help me?
EDITED
I am pretty sure that none of these steps should be the reason for the fail, the second one only the closest one, because my build steps are
Team City build steps look like the following.
Step XX:
cd %projectDirectory%
"C:\sonarqube-5.3\bin\MSBuild.SonarQube.Runner\MSBuild.SonarQube.Runner.exe" begin ... params
"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\msbuild.exe" "MyProject.sln" /t:Clean;Rebuild
Step XY:
...
Step XZ: (the last)
cd %projectDirectory%
"C:\sonarqube-5.3\bin\MSBuild.SonarQube.Runner\MSBuild.SonarQube.Runner.exe" end
For me it looks very simple and easy to understand, but still I got that error and I have no idea why, the error is thrown in the last step (XZ).
You need to upgrade to a newer version of the Scanner for MSBuild. I'd suggest upgrading to the newest available version (v4.2 at the time of writing).
The scanner copies a targets file under the following location for each supported version of MBuild: %localappdata%\Microsoft\MSBuild[MSBuild version]\Microsoft.Common.targets\ImportBefore.
From the look of the log output you are using an version of the Scanner for MSBuild that pre-dates the release of MSBuild 15, so the file won't be copied to the MSBuild15-specific location. This will lead to the "no ProjectInfo.xml files were found" state.
It would be better if the warning message in the scanner log explicitly listed the range of MSBuild versions that were supported e.g. "This version of the Scanner supports MSBuild v12.0 to v14.0". I've created issue #502 to track this.

Web Performance Test - could not load type 'Microsoft.VisualStudio.WebTesting.SharepointInformation'

I installed VS.2017 Enterprise and start a web performance project. When I try to add a Web performance test to the project I receive the error:
"The Web test could not be loaded: Could not load the type
'Microsoft.VisualStudio.TestTools.WebTesting.SharepointInformation'
from assembly 'Microsoft.VisualStudio.QualityTools.WebTestFramework'
Version=10.0.0.0, .."
TL;DR:
Check installed prerequisites in the latter part of Create a web performance and load test project
In my case, replacing original file
C:\windows\assembly\GAC_MSIL\Microsoft.VisualStudio.QualityTools.WebTestFramework\10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.QualityTools.WebTestFramework.dll
with
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\ReferenceAssemblies\v4.0\Microsoft.VisualStudio.QualityTools.WebTestFramework.dll solved the problem.
I tackled the same issue. Every time I created Web Performance and Load Test Project in Visual Studio 2017 Enterprise (with arbitrary .NET framework version) I got the same error when I tried to open *.webtest file. VS's user interface seemed incomplete and clicking on toolbars sometimes shown null exceptions.
At first, I thought I have incomplete installation, according to Create a web performance and load test project. I have even tried to completely uninstall and reinstall mentioned packages. Unfortunately, this did not help. I have also experimented with adding and removing reference to Microsoft.VisualStudio.QualityTools.WebTestFramework as there are several options in my reference browser, but without success.
There is not much information about WebTesting.SharepointInformation namespace. After a while, I discovered the existence of Microsoft.VisualStudio.QualityTools.WebTest.SharePoint.dll and after closer inspection, I have noticed that it references QualityTools.WebTestFramework assembly in C:\Windows\assembly\... that has the same assembly version and public key token, yet smaller in size compared to the one that is contained in VS 2017 installation. I have replaced it with VS2017's one and voila, *.webtest can be successfully opened.
The above answer is correct but the problem is the directory isn't accessible in my case due to some reasons so I just open my cmd and run this command. Just run, it will copy the file, but first turn of the vs.
copy "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\ReferenceAssemblies\v4.0\Microsoft.VisualStudio.QualityTools.WebTestFramework.dll" "C:\windows\assembly\GAC_MSIL\Microsoft.VisualStudio.QualityTools.WebTestFramework\10.0.0.0__b03f5f7f11d50a3a"

How can I resolve the error: "The command [...] exited with code 1"?

I've read around many questions but I've not been able to find the right answer for me.
As I try to compile a project in VS2012 I have this result:
The command "....\tools\bin\nuget pack Packages\Lib.Html.nuspec - OutputDirectory ....\bin\Zip\Packages -NoPackageAnalysis" exited with code 1.
I looked for the line of code in my .csproj file, where the error should be, and there is:
<Exec Command="$(ProjectDir)..\..\tools\bin\nuget pack $(ProjectDir)Packages\Lib.Html.nuspec -OutputDirectory $(OutputPath)Packages -NoPackageAnalysis" />
What am I doing wrong?
[EDIT]
Launching the Debug of that project and ignoring "building errors", I have a new alert:
"Visual Studio cannot start debugging because the debug target '[project.exe path]' is missing.
Please build the project and retry, or set OutputPath and AssemblyName properties appropriately to point at the correct location for the target assembly."
The first step is figuring out what the error actually is. In order to do this expand your MsBuild output to be diagnostic. This will reveal the actual command executed and hopefully the full error message as well
Tools -> Options
Projects and Solutions -> Build and Run
Change "MsBuild project build output verbosity" to "Diagnostic".
Right click project -> Properties -> Build Events
Remove the text in Post-build event command line text block
For me : I have a white space in my path's folder name G:\Other Imp Projects\Mi.....
Solution 1 :
Remove white space from folder
Example: Other Imp Projects ->> Other_Imp_Projects
Solution 2:
add Quote ("") for your path.
Example: mkdir "$(ProjectDir)$(OutDir)Configurations" //see double quotes
Try to open Visual Studio as admin.
For me, in VS 2013, I had to get rid of missing references under References in the UI project (MVC). Turns out, the ones missing were not referenced.
I know this is too late for sure, but, this could help someone as well.
In my case, i found that the source file is being used by another process which was restricting from copying to the destination. I found that by using command prompt ( just copy paste the post build command to the command prompt and executed gave me the error info).
Make sure that you can copy from the command prompt,
This builds on the answer from JaredPar... and is for VS2017. The same "Build and Run" options are present in Visual Studio 2017.
I was getting, The command "chmod +x """ exited with code 1
In the build output window, I searched for "Error" and found a few errors in the same general area. I was able to click on a link in the build output, and found that the error involved this entry in the .targets file:
<Target Name="ChmodChromeDriver" BeforeTargets="BeforeBuild" Condition="'$(WebDriverPlatform)' != 'win32'">
<Exec Command="chmod +x "$(ChromeDriverSrcPath)"" />
</Target>
In the build output, I also found a more detailed error message that essentially stated that it couldn't find Selenium.WebDriver.ChromeDriver v2.36 in the packages folder it was looking in. I checked the project's NuGet packages, and version 2.36 was indeed in the list of installed packages. I did find the package files for 2.36, and changed the attributes on the folder, subfolders and files from "Read Only" to "Read/Write". Built, but same failure. Sometimes "updating" to a different version of the package and then updating back to the original can fix this type of error. So I "updated" the reference in Manage NuGet packages to 2.37, built, failed, then "updated" back to 2.36, built, and the build succeeded without the "chmod +x" error message.
The project I was building was based on a Visual Studio Project template for Appium test tooling, template name "Develop_Automated_Test".
Check your paths:
If you are using a separate build server for TFS (most likely), make sure that all your paths in the .csproj file match the TFS server paths. I got the above error when checking in the *.csproj file when it had references to my development machine paths and not the TFS server paths.
Remove multi-line commands: Also, try and remove multi-line commands into single-line commands in xml as a precaution. I had the following xml in the *.proj that caused issues in TFS:
<Exec Condition="bl.."
Command=" Blah...
..." </Exec>
Changing the above xml to this worked:
<Exec Condition="bl.." Command=" Blah..." </Exec>
I had the same issue. Tried all the above answers. It was actually complained about a .dll file. I clean the project in Visual Studio but the .dll file still remains, so I deleted in manually from the bin folder and it worked.
Hope this helps someone, but I had prebuild events and post build events and it kept complaining about a file called "Microsoft.Common.CurrentVersion.targets" "The target "CoreBuild" does not exist in the project".
Here's what I did to resolve it:
close the project
delete the .suo file (it regenerates)
Asked a team member to provide a copy of that file (Microsoft.Common.CurrentVersion.targets) - mine was different - I took his.
It compiled - good to go.
I must have wrecked that file somehow.
There was no syntax error in my batch file and it ran fine on a cmd prompt outside VS.
So finally, I added
exit 0
to return a success code explicitly at the end of my batch file and it started working.
For me the output file (.dll) of the same version already existed so I guess it was having trouble overwriting. Even though it has never done it before. Anyways, deleting the existing file and running Rebuild fixed it for me.
If the previous method wouldn't have fixed it, my next check would have been to check if the path length was causing it. So would have change the target folder to somewhere close like the Desktop so that the path isnt too long.
Hint: Search for "Exec Command=" in your project
In my case I found following tag in "Microsoft.Extensions.ApiDescription.Server.targets" file, I remarked the line and it worked for me:
<Exec Command="$(_Command)" LogStandardErrorAsError="true" />

How to find the reason for a failed Build without any error or warning

I have a WebApplication which contains reference to WCF services.
While building using Visual Studio 2010, Build fails without any error or warning. However building the .csproj using MsBuild is successful.
Can't figure out what should I try in Visual Studio, to resolve / diagnose the issue. Can you please help out?
I find out that the build has been failing,
From text displayed in status Bar.
From output window:
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========
The output tab includes configuration details.
------ Build started: Project: <projectName here> Configuration: Debug Any CPU
I noticed that if "Build + Intellisense" is selected in the Error List, it causes the error messages to be swallowed.
Change this option to "Build Only", and all error messages will be displayed:
I don't know if this is a bug in Visual Studio or what, but it certainly revealed hidden error messages that were the key to pinpointing the failure for me.
Some, like Richard J Foster, have suggested increasing the "MSBuild project build output verbosity" setting to "Diagnostic" (the highest possible option), but this didn't solve the problem for me, as Visual Studio appeared to be suppressing the error message(s) themselves.
As an alternative, you may try to use the raw output messages from the "Output" tab, which haven't been filtered by Visual Studio. Either do an in-place search for the strings "error" and/or "failed", or copy all of the output to your favorite text editor and do a search there.
To ensure that the Output window appears each time you do a build, you can go to Tools → Options → Projects and Solutions → General, and ensure that the option "Show Output Window when build starts" is checked.
As an additional troubleshooting step, it is also possible to build the project from the PowerShell command line by running dotnet build. This will show you the complete build output, including any errors that Visual Studio may be hiding.
I just ran into a similar situation. In my case, a custom action (from the MSBuildVersioning package available on Nuget.org - http://www.nuget.org/packages/MSBuildVersioning/) which appeared in the csproj file's BeforeBuild target was failing without triggering any error message in the normal place.
I was able to determine this by setting the "MSBuild project build output verbosity" (in the latest Visual Studio's Tools tab [Path: Tools > Options > Build and Run]) to "Diagnostic" as shown below. This then showed that the custom action (in my case HgVersionFile) was what had failed.
Here are some things that you can try:
If your solution contains more than one project, try building each project one at a time. (You may even want to try opening each project independently of the solution.)
If applicable, ensure that all of your projects (including dependencies and tests) target the same version of the .NET Framework. (Thanks to user764754 for this suggestion!)
Tip: Check Tools → Extension and Updates to ensure that your packages are up-to-date.
Ensure that all dependency projects are built to target the same platform as your main project.
Try restarting Visual Studio.
As suggested by Bill Yang, try running Visual Studio as Administrator, if you aren't already. (If you are already running Visual Studio as Administrator, perhaps try the opposite?)
Try restarting your computer.
Try "Rebuild All".
Run "Clean Solution", then remove your *vspscc* and *vssscc* files, restart Visual Studio, and then "Rebuild All".
As suggested by Andy, close Visual Studio, delete the .suo file, and restart Visual Studio.
As suggested by Arun Prasad E S, close Visual Studio, delete the .vs folder in your solution directory, and then re-open Visual Studio. (This folder is auto-generated by Visual Studio and contains cache, configuration settings, and more. More details can be found in these questions: Visual Studio - Deleting .vs folder and https://stackoverflow.com/q/48897191.)
As suggested by MrMalith, close Visual Studio, delete the obj folder in your solution directory, clear your temporary folder, and then re-open Visual Studio.
Delete the hidden .vs folder & restart Visual Studio. That worked for me.
I want to expand on Sasse's answer. I had to target the correct version of .NET to resolve the problem.
One project was giving me an error:
"The type or namespace name 'SomeNamespace' does not exist in the namespace 'BeforeSomeNamespace' (are you missing an assembly reference?)".
There was no error in the Error List window but the assembly had a yellow warning sign under "References".
I then saw that the referencing project targeted 4.5.1 and the referenced project 4.6.1. Changing 4.6.1 to 4.5.1 allowed the overall build to succeed.
Nothing was working for me so I deleted the .suo file, restarted VS, cleaned the projected, and then the build would work.
I tried many things like restarting Visual Studio, cleaning and rebuilding the solution, restarting the PC, etc., but none of them worked for me. I was finally able to solve the problem by doing the following:
First of all, make sure all the projects in your solution (including tests) are targeting the same .NET version. Then:
Save pending changes in the project and close Visual Studio
Find the exact location from file explorer and find "obj" file and open it,
Then, delete all the included files (some files won't remove, it doesn't matter, just skip them).
Use run command (by pressing Windows Key + R) and type "%temp%" and press enter to find temporary files.
Finally, delete them all.
On other possibility is that Visual Studio needs to run as Administrator, this might be related to deploying to local IIS server or other deployment need.
Just for the sake of completion and maybe helping someone encountering the same error again in the future, I was using Mahapps metro interface and changed the XAML of one window, but forgot to change the partial class in the code-behind. In that case, the build failed without an error or warning, and I was able to find it out by increasing the verbosity of the output from the settings:
In my case (VS 2019 v16.11.20), disabling Text Editor->C#->Advanced->Enable 'pull' diagnostics in the options solved the issue.
Double check for _underscore.aspx pages in your project.
I had a page and code-behind:
`myPage.aspx` and `myPage.aspx.vb`
when building the project, I'd get errors on the .aspx.vb page stating that properties defined on the .aspx page didn't exist, even though the page itself would build fine and there were NO OTHER ERRORS showing in the output (even with diagnostic level build output).
I then came across a page in the project that was named the same thing but with an underscore: _myPage.aspx - not sure where it came from, I deleted it, and the solution built fine.

Categories

Resources