Visual Studio 2015 builds my project without problems, MSBuild.exe cannot - c#

I am developing simple Asp.net MVC 5 app which is working ok and visual studio 2015 can build it without any issues, but when i use MSBuild.exe command line tool it shows alot of errors which relates to typescript files compilation (primarily from node_modules folder).
I am trying to use Jenkins CI tool to automate my deployment routine, in order to do so i have to build my app using MSBuild.exe.
My project has tsconfing.json file in the root folder which contains following lines to exclude node_modules folder (it is inside #AngularComponents folder):
"exclude": [ "Scripts/**", "WrittenScripts/#AngularComponents/**" ]
But somehow MSBuild.exe command line tool just ignores it during build.
Does anyone have any ideas how to configure it to take into account my tsconfig? or tell MsBuild to not to build my node_modules folder?
Thank you in advance!

I finally figured it out.
First of all i have to use this MsBuild:
1) C:\Program Files (x86)\MSBuild\14.0\Bin\msbuild.exe;
Secondly, for some reason msbuild messed up my tools version 4.0 so I need to pass additional parameter to msbuild:
2) /tv:14.0
Thirdly, my typescript files have some /// references to node_modules\#types folder and for some reason it shows me any errors but not related to the reference one.
3) so i have to run npm install to recover #types packages.
After these steps msBuild builds successfully without any errors.
Thanks for all!

Related

CI with Jenkins MSB3202 Error while building job with subproject

I need some help from you.
In our team we want to build our .Net project in Jenkins. The project consists of subprojects that are added via the .csproj files. Now we have the problem that the Jenkins is thrown with the building of the individual subprojects due to the relative path, which is in the .sln file, following error:
MSB3202: The project file "xxxx..\xxx.csproj was not found. [C:xxxxx\x.sln]
Has anyone needed a solution like us to build our project structure to build every single project in Jenkins as a job? Or are there possible solutions for this error in Jenkins?
Thanks in advance
it s about msbuild.exe version. try to upgrade
choose upper version
Go to Manage Jenkins -> Global Tool Configuration -> MSBuild
Add upper version like this

How to properly build MSI Setup Projects using Azure DevOps Pipelines?

I have been pulling my hair for the past couple days trying to figure out how set up a CI/CD process just to build a simple WPF solution and create the MSI setup file ("artifact") using Azure DevOps Pipelines. I have tried using Build VS Installer to accomplish this. My main problem is that I don't know exactly what am I doing wrong or what steps I am missing and I can't find clear instructions on this anywhere.
Here's what I've tried:
Using the Hosted 2017 agent pool and the basic .NET Desktop Template. Problems:
Create .msi file(s) from VS Installer project(s) as last task or before publishing artifact):
2018-11-28T22:57:56.3186071Z DEBUG: Aggregated: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\devenv.com
2018-11-28T22:57:56.3211382Z Now running (C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\devenv.com) with Arguments ("D:\a\1\s" /Build "release|any cpu" /Out "D:\a\1\b\BuildInstaller_Log_20181128225756.txt")
2018-11-28T22:58:54.0015320Z Done running DevEnv process. Success = True.
2018-11-28T22:58:54.1169279Z ##[warning]No .MSI files were found, please check your build-configuration. If this is expected, you might consider to use the default Visual Studio Build task instead of this custom Installer task.
2018-11-28T22:58:54.1434410Z ##[section]Finishing: Create .msi file(s) from VS Installer project(s).
Creating my own build agent as outlined in the documentation. I have Visual Studio Community 2017 with the VS Installer Projects extension installed on that server. I followed the steps from this related answer. Results:
2018-11-29T17:46:03.9813075Z DEBUG: Aggregated: System.Object[]\devenv.com
2018-11-29T17:46:04.4346060Z ##[error]Cannot retrieve the dynamic parameters for the cmdlet. The specified wildcard character pattern is not valid: System.Object[]
2018-11-29T17:46:04.4716416Z ##[section]Finishing: Create .msi file(s) from VS Installer project(s).
I also tried DevEnv Build from the market place instead of the DutchWorkz one and still couldn't get an .msi file. Can someone please show me some clear steps on how to achieve this simple goal?
I was able to figure out why I was getting the specific error message below and wanted to share in case it helps anyone out in the future.
DEBUG:
Aggregated: System.Object[]\devenv.com
[error]Cannot retrieve the dynamic parameters for the cmdlet. The specified wildcard character pattern is not valid: System.Object[]
The issue was that I had two versions (Professional and Enterprise) of Visual Studio 2017 installed on my private build server. Once I removed one of them, everything worked great. Not sure if there's a way to get it working with both installed, but I didn't need both.
Microsoft Visual Studio Installer Projects extension is present in windows-latest runner. Find more here
In short, use an agent with windows-latest vmimage and build via devenv.exe instead of MSBuild.

Microsoft.CSharp.Core.targets missing

I am building a webservice project on a TFS2017 Update 3 with build tools 2017. I get the following error
C:\Program Files (x86)\Microsoft Visual
Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.CSharp.CurrentVersion.targets(322,5):
Error MSB4019: The imported project "C:\Program Files (x86)\Microsoft
Visual
Studio\2017\Enterprise\MSBuild\15.0\Bin\Roslyn\Microsoft.CSharp.Core.targets"
was not found. Confirm that the path in the declaration is
correct, and that the file exists on disk.
What steps do I need to take to fix this error?
In my case, opening the existing Solution file (with .sln extension), it installed all the missing dependencies.
Otherwise check for missing target packages at nuget.org manually and install them (e.g. MSBuild.Microsoft.VisualStudio.Web.targets).
As per this GitHub issue, you'll need to set $(RoslynTargetsPath).
If MSBuild is installed on the machine and your tests run in a Visual Studio Developer Command Prompt, then you shouldn't need to do anything. However, MSBuild 15.0 no longer places itself in the registry which makes it impossible for MSBuild to find itself. This is because of a mandate by Visual Studio where you can have multiple side-by-side installations. MSBuild in this case would be installed once per Visual Studio instance. MSBuild now finds itself by looking at environment variables set by the VS command prompt.
If you want to fully redistribute MSBuild via a combination of our packages and all of the other packages needed to do full project evaluation, you will have to set RoslynTargetsPath before you load projects. You could argue this is an issue with NuGet since all packages' <contentFiles /> go to the the root of your output directory and you can't specify a subdirectory for certain packages.
If you're coming to this page from google/duckduckgo after trying to figure out why you're getting a similar message in Ubuntu 20.04, maybe this can help: https://askubuntu.com/a/1231973/1073658 (tl;dr apt install mono-roslyn from mono-project's repo)
First suggest you directly use msbuild command on the build agent with TFS build service account. This will narrow down if the issue is related to your agent environment or your TFS build definition.
According to your error info, the path C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Roslyn\Microsoft.CSharp.Core.targets is looking the path of Visual Studio 2017.
However, for Build Tools the path is different should be C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\Roslyn
Seems you haven't installed VS2017 on your build agent. This maybe the root cause of the issue.
The simplest solution is installing VS2017 on your build agent. Note, you need to reconfigure the build agent or restart build agent service to capture those new capabilities. Otherwise you need to change the corresponding import section in your .csproj project files.
I updated to TFS2018 and the problem got solved.

TFS Build Server won't deploy my .pdbs

The steps of my build:
NuGet Installer - get all packages for all solutions in the source tree
Visual Studio Build - Build the solution - no special parameters
Visual Studio Test - Run tests on built solution
Visual Studio Build - Publish specific website - MSBuild Arguments = /p:DeployOnBuild=true /p:PublishProfile=Publish /p:OutputPath=Publish /p:TeamDirectory="$(TeamName)\\" /p:ExcludeGeneratedDebugSymbol=false
Publish Build Artifacts
Additional configuration:
Going to properties for the website in VS, all build configurations have "Exclude generated debug symbols" unchecked. This is reflected in the .csproj file with <ExcludeGeneratedDebugSymbol>false</ExcludeGeneratedDebugSymbol> under each PropertyGroup.
Going to properties for the website in VS, under Build -> Advanced, all build configurations have Debug Info = pdb-only (except Debug, which has full). This is reflected in the .csproj file with <DebugType>pdbonly</DebugType> and <DebugSymbols>true</DebugSymbols>
The bin directory for all projects including the website contains appropriate .pdb files. The Publish directory and the generated artifact do not have any .pdb files except for Antlr3.Runtime.pdb, EntityFramework.MappingAPI.pdb, and RefactorThis.GraphDiff.pdb. Running publish locally through VS copies the .pdb files as expected.
I tested at my side, TFS has the same behavior with local VS, it's the default behavior.
Normally the Antlr3.Runtime.pdb and project project.pdb will display there, If you have other third packages, you need to make sure the .pdb files are included in them when get sources.
Whatever, have a try for these arguments /p:DebugSymbols=true /p:DebugType=full

Publishing web application failed

When publishing my web application, I get the following error:
Done executing task "CopyPipelineFiles" -- FAILED.
Done building target "CopyAllFilesToSingleFolderForPackage" in project
"ServiceManagement.csproj" -- FAILED.
Done building project "ServiceManagement.csproj" -- FAILED.
I use Visual Studio 2015. I also tried opening it in administrator mode.
One possible cause is, if you have included some files in the project that are not necessary to compile (like PowerPoint files or word files), & then removed the files from the hard drive, but forgot to delete them in the "Solution Explorer" inside Visual Studio - then "Rebuild Solution" will work b/c those files were not necessary to compile - but "Publish" will fail b/c it cannot find those files when Visual Studio tries to copy files to the publish destination.
I was able to fix it with the following actions:
Remove all unrelated scripts and libraries that you are not using on your project.
Remove all src folders on your scripts.
Since I copied the whole project script files with its corresponding directories, this was I think the main issue that cause the publishing to fail as some filenames are long.
I retain only the one javascript file and one minified file, the same way with CSS files.
If you weren't able to still solve the issue after doing the actions above, try the following (Either of this actions works for us.):
Try to rebuild the project on a different machine.
I am using Visual Studio 2015 Professional Edition so I tried the Visual Studio 2017 to build and publish it.
I kind of had this issue and was because of a corrupted file that couldn't sync in OneDrive. I had a folder that coudn't be opened or deleted with the message "tag present in the reparse point buffer is invalid". By making a "chkdsk /r /f" in a Command Prompt (w/ admin permissions) my build was fixed and I could publish it again in Azure.

Categories

Resources