I am trying to compile a C VS project from PowerShell using msbuild. The command I'm using for now is:
msbuild .\my_solution.sln /t:Rebuild /p:Configuration=Release
But when I try to build I get the following error:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.Cpp.props(31,5): error MSB4186: Invalid static method invocation syntax: "[Microsoft.Build.Utilities.ToolLocat
ionHelper]::FindRootFolderWhereAllFilesExist($(_VCTargetsPathFolders), $(_RelativeToolsetFiles))". Method 'Microsoft.Build.Utilities.ToolLocationHelper.FindRootFolderWhereAllFilesExist' not found. Static meth
od invocation should be of the form: $([FullTypeName]::Method()), e.g. $([System.IO.Path]::Combine(`a`, `b`)).
I have already tried the following:
Run as admin
Repair Visual Studio
Full uninstall and reinstall of Visual Studio.
Other useful info:
I am using Visual Studio Community 2019.
My msbuild path is: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin
My VCTargetsPath is: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\
Worth noting that on the CLI command I haven't added the additional include directories nor the additional dependencies while in the UI version I have. Despite this, the error I am expecting is somewhat like unknown reference to <function>. I am trying to solve this first error before proceeding to link the required libraries, I don't believe this causes the problem but I'm mentioning it just in case.
The strange thing is that if I rebuild using the Visual Studio UI the project builds without any problem.
Despite this, I need to build from CLI so I would be really thankful if someone shares where the problem may be.
Check your MSBuild version, I've had the same problem time ago.
For example:
msbuild
Microsoft (R) Build Engine version 4.0.30319 for .NET Framework
In my case (now), the latest version is 16.9.0 (Downloaded from here)
Microsoft (R) Build Engine version 16.9.0+57a23d249 for .NET Framework
Check your Windows Path, when I got the problem, I got a Windows Path that contains an older version of MSBuild, checking the folder I saw "msbuild.exe". I Removed that entry and put the new one for my good msbuild.
%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin
Seen on this post
This works well in my side with your description. So your environment has some problems.
Try these:
1) close VS IDE, run Developer Command Prompt for VS2019 as Administrator
type:
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Build.Framework.dll"
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Build.dll"
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Build.Engine.dll"
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Build.Conversion.Core.dll"
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Build.Tasks.Core.dll"
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Build.Utilities.Core.dll"
After that, restart it to test again.
This is up to your wish:
If it does not help, please run C:\Program Files (x86)\Microsoft Visual Studio\Installer\resources\app\layout\InstallCleanup.exe to uninstall all VS2017 andVS2019 versions with their registration information, any data. This is like a strong, thorough uninstallation.
Then, reinstall the version.
Related
Visual studio 2017 and i am installed all required build tools .but when i run react-native run-windows . It show error like below code
C:\native\myapp>react-native run-windows
Restoring NuGet packages
Building C:/native/myapp/windows/com.tet.windows.sln
Found MSBuild v15.0 at C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin
Building Solution: C:/native/myapp/windows/com.tet.windows.sln
Build configuration: Debug
Build platform: x86
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
C:\native\myapp\windows\com.tet.windows\com.tet.windows.csproj(171,11): error MSB4226: The imported project "C:\Program
Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\WindowsXaml\v15.0\Microsoft.Windows.UI.Xaml.CSha
rp.targets" was not found. Also, tried to find "Microsoft\WindowsXaml\v15.0\Microsoft.Windows.UI.Xaml.CSharp.targets" i
n 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\Enterprise\MSBuild\15.0\bin\msbuild.exe.Config". Confir
m that the path in the <Import> declaration is correct, and that the file exists on disk in one of the search paths.
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\VC\VCTargets\Microsoft.Cpp.Current.targets(1
08,3): error MSB4019: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\
VC\VCTargets\Platforms\Win32\Platform.targets" was not found. Confirm that the path in the <Import> declaration is corr
ect, and that the file exists on disk. [C:\native\myapp\node_modules\react-native-windows\Folly\Folly.vcxproj]
Build failed with message Error: Command failed: "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\msbuild.exe" "C:/native/myapp/windows/com.tet.windows.sln" /clp:NoSummary;NoItemAndPropertyList;Verbosity=quiet /nologo /p:Configuration=Debug /p:Platform=x86 /p:AppxBundle=Never /p:PlatformToolset=v141 /p:VisualStudioVersion=15.0. Check your build configuration.
I have got similar issue due to starting using VS 2019. All it says is that go to this file:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\bin\msbuild.exe.Config
open it and find what is in this node:
<projectImportSearchPaths>
<searchPaths os="windows">
Change the value to navigate exactly where your MSBuild is right now. In my case, the change was:
<projectImportSearchPaths>
<searchPaths os="windows">
<property name="MSBuildExtensionsPath" value="$(MSBuildProgramFiles32)\Microsoft Visual Studio\2019\Enterprise"/>
<property name="MSBuildExtensionsPath32" value="$(MSBuildProgramFiles32)\Microsoft Visual Studio\2019\Enterprise"/>
<property name="MSBuildExtensionsPath64" value="$(MSBuildProgramFiles32)\Microsoft Visual Studio\2019\Enterprise"/>
<property name="VSToolsPath" value="$(MSBuildProgramFiles32)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VisualStudio\v$(VisualStudioVersion)"/>
</searchPaths>
</projectImportSearchPaths>
value: Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VisualStudio
Hope it helps.
I have a cordova project and I added windows platform but when I run the project I have this error:
MSBuild v4.0 is not supported, aborting.
Error: AppPackages doesn't exists
Try to set OS environment variable
VSINSTALLDIR = C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\
which points to your Visual Studio folder with MSBuild directory.
You have of install Microsoft Build Tools:
https://www.visualstudio.com/downloads/
Navigate to Other Tools and Frameworks
Download Build Tools for Visual Studio 2017
After, set OS environment variable VSINSTALLDIR = C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\ which points to your Visual Studio folder with MSBuild directory
I need to intercept an SSDT build to modify the build script. I've followed the MSDN Deployment Plan Modifier tutorial, but when I attempt to build the database project, I get the following error:
Required contributor with id 'MyDeploymentContributor.SqlRestartableScriptContributor'
could not be loaded.
I am using Visual Studio 2012 (Version 11.0.61219.00 Update 5) and SSDT Version 11.1.50730.0.
I signed the assembly but did not specify a password.
I've followed several solutions I've found online to no avail, including the following:
Updating Visual Studio and SSDT;
Copying MyDeploymentContributor.dll and MyDeploymentContributor.pdb to the following locations:
C:\Program Files (x86)\Microsoft SQL Server\110\DAC\bin\Extensions
C:\Program Files (x86)\Microsoft SQL Server\110\DAC\bin
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\120
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\120\Extensions
Capturing an event log for SSDT and DacFx (following Kevin Cunnane's instructions at https://social.msdn.microsoft.com/Forums/en-US/5c84ab8e-b50b-4ecd-86da-866ac3bb2248/known-issue-with-ssdt-extensibility-in-current-release?forum=ssdt). Here are the results from the DacFx log:
Core Services: SafeDirectoryCatalog: Assembly C:\Program Files
(x86)\Microsoft Visual Stusio 11.0\Common7\IDE\Extensions\Micrsoft\SQLDB\DAC\120\Extensions\MyDeploymentContributor.dll
added
Core Services: Extension Lookup: directory C:\Program Files
(x86)\Microsoft Visual Stusio 11.0\Common7\IDE\Extensions\Micrsoft\SQLDB\DAC\120\Extensions added to extension lookup path
Core Services: FilteringCompositionContainer: Looking up exports for
Microsoft.SqlServer.Dac.Deployment.DeploymentPlanExecutor
Core Services: FilteringCompositionContainer: Changed part creation policy
to NonShared
Core Services: FilteringCompositionContainer: Looking up exports for
Microsoft.SqlServer.Dac.Deployment.DeploymentPlanModifier
There were no ContributorLoader messages. From this log, the contributor seems to be loading correctly. The SSDT log didn't contain any events that mentioned the contributor.
There are no required contributor arguments, so the DeploymentContributor node in my .sqlproj file looks like this:
<PropertyGroup>
<DeploymentContributors>
$(DeploymentContributors); MyDeploymentContributor.SqlRestartableScriptContributor
</DeploymentContributors>
</PropertyGroup>
Any help is appreciated. Thanks!
Thanks to Ed Elliot ( https://the.agilesql.club/Blogs/Ed-Elliott/About ), I was able to resolve this issue in my case.
I followed Ed's suggestions and it worked. I created a folder like C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\120\Extensions\[YourContributorName]\ and copied all the contents (including DLLs) from C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\120 to there.
In the contributor project, I referenced the DLLs inside C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\120\Extensions\[YourContributorName]\
Once the project was built successfully, I copied the contributor .dll and .pdb files to the following location:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\120\Extensions\[YourContributorName]\
Before, I was referencing the DLLs from C:\Program Files (x86)\Microsoft SQL Server\110\DAC\bin.
Hope this would help someone.
I am trying to use the SketchFlow Template for Windows Phone (http://wp7sketchflow.codeplex.com) with Blend for Visual Studio 2013 and when I try to create a project with the template I get this error:
New Project failed. Could not find file "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Blend
Preview\ProjectTemplates\en\CSharp\WindowsPhone\WindowsPhone\csWindowsPhonePrototype.zip[ControlLibrary\AssemblyInfo.cs].
I have looked inside the directory and the file does file exist. Does anyone have a solution? The only other stuff I found is http://wp7sketchflow.codeplex.com/discussions/429011.
Thanks,
I've also posted to that thread with a solution. Which I will also add here.
I've posted a fix for using this template with SketchFlow that ships in Blend/VS2013 (may work in 2012 but I didn't test).
Please read my instructions I've tried to be a clear as possible.
You WILL need to download and install the SketchFlowWP7.zip file from this codeplex (I also provide a copy in the link below).
Extract SketchFlowWP7.zip and run the SketchFlowWP7.msi to install.
When it prompts where to install choose the path to your copy of Blend. For instance for VS2013 it's default path is "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Blend"
Next you will need to navigate down into the following folder "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Blend\ProjectTemplates\en\CSharp\WindowsPhone"
Here you will find a file names csWindowsPhonePrototype.zip, delete it. Yes really delete it, you are going to be replacing it's contents in the next steps.
Download the csWindowsPhonePrototype.zip from the following linkg - http://sdrv.ms/1hED9Cm
Extract the contents of csWindowsPhonePrototype.zip and you will have a folder called csWindowsPhonePrototype
Move the extracted folder into the "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Blend\ProjectTemplates\en\CSharp\WindowsPhone" directory. PLEASE make sure that you don't have a folder called csWindowsPhonePrototype inside of it, if you do it's that child folder you need to move.
Now when you fire up Blend you should see an option for SketchFlow for Windows Phone.
I am trying to do an automated build using the command line for Visual Studio 2003. I have the following codes:
call "C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools\vsvars32.bat"
Devenv /rebuild debug /project Project1 "C:\Builds\MyApp\Sample.sln"
Devenv /rebuild debug /project Project2 "C:\Builds\MyApp\Sample.sln"
Devenv /rebuild debug /project Project3 "C:\Builds\MyApp\Sample.sln"
In my script above, I build each project individually (like I saw in a tutorial on the internet). But each time I try to build, it throws me a lot of errors about the Microsoft Namespaces not being found. Below are sample error messages I get on the build:
Namespace or type 'Data' for the Imports
'Microsoft.Practices.EnterpriseLibrary.Data' cannot be found.
Namespace or type 'Sql' for the Imports
'Microsoft.Practices.EnterpriseLibrary.Data.Sql' cannot be found.
Namespace or type 'Logging' for the Imports
'Microsoft.Practices.EnterpriseLibrary.Logging' cannot be found.
Satellite assemblies could not be built because the main project
output is missing.
I have tried another method to build but this time it's the entire solution but still it gives me the same errors.
call "C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools\vsvars32.bat"
Devenv C:\Builds\MyApp\Sample.sln /rebuild "Debug"
Can somebody please tell me what i'm missing?
I have over 50 projects in a single solution and it would really help me big time to create an automated build for this.
Thanks a lot! Cheers!
Don't "call" the "vsvars32.bat" file.
Use the full path for "Devenv.exe" (instead of #1).
Optionally: (maybe this is the kicker)..... cd to the directory where the .sln file resides.
"c:\myfullpath\Devenv.exe" /rebuild debug /project Project1 "C:\Builds\MyApp\Sample.sln"
Try that from the command line and see what happens.
Future Note:
In 2.0, you do NOT use "devenv.exe", you change it to msbuild.exe. (Just as an FYI).
You can also look up MSBee. (How to build 1.1 apps with msbuild).
EDIT
All of these lines are working for me.......I don't have VS2003 installed anymore. But I used VS2010 devenv.exe to run some samples.
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe" MySolution.sln /clean
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe" /build debug /project MyProject001 MySolution.sln
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe" /rebuild debug /project MyProject001 MySolution.sln
Note, if I switch the /clean with the MySolution.sln (in the first example).....it fails. So there may be some ordering voodoo.
I'm not sure exactly what you want but to automate the compilation of my C# projects I use msbuild.
For example this is a code I use to build some XNA project games:
Sample Code:
#echo off
set path=%path%;C:\Windows\Microsoft.NET\Framework\v4.0.30319
Rem In the above line replace "v4.0.30319" with the latest framework version you have
Rem (or include the path to youy inbuilt compiler)
Msbuild "C:\Builds\MyApp\Sample.sln"
Now to meet any other requirements you want you can just type msbuild /? after you added it to your path environemtn variable. The best thing is this will be inbuilt for every windows computor!
Please ask if you want to know anything else, or if you want to do something else.
Try this:
Each of your Projects should have a reference to the "Microsoft.Practices.EnterpriseLibrary" - Files, dlls or whereever these are stored.
Maybe during an open IDE one holds a reference and copies it to the correspodending build folder. (After Build Task). While builing it independly the references could not be found.
If any copy tasks exist - Check the relative paths. Maybe your depended files targets to a different folder after build compared to build in the IDE.?
Just another idea..