dotnet build/msbuild fails on GenerateResource Task with .NET 6 - c#

I try to build my project in my CI/CD pipeline with a gitlab runner, but I always end in the following error message:
C:\Program Files\dotnet\sdk\6.0.100\Microsoft.Common.CurrentVersion.targets(3264,5): error MSB4216: The GenerateResource task could not be performed because MSBuild could not create a task host or connect to a task host with runtime CLR4 and architecture x86. Make sure that (1) the requested runtime and/or architecture is available on the computer and (2) the required executable file "C:\Program Files\dotnet\sdk\6.0.100\MSBuild.exe" exists and can be executed. [project_path]
C:\Program Files\dotnet\sdk\6.0.100\Microsoft.Common.CurrentVersion.targets(3286,7): error MSB4028: The output of the GenerateResource task could not be retrieved from the FilesWritten parameter. Object does not match target type. [project_path]
I´ve installed .NET6 SDK with version 6.0.100.
It seems like its trying to find the msbuild.exe and it´s not there. I´ve copied the file temporarely but this causes a endless building without result or error message.
Am I missing something? In my Visual Studio 2022 the build process is working and generating my binaries.

Related

C# ScriptTask not working when run through Dtexec or SQL Server

Identical question with no answers.
I have an issue with my SSIS projects where I cannot create a project that has a
Microsoft.ScriptTask in it without encountering some bizarre error messages. The underlying issue is that the content of the Microsoft.ScriptTask doesn't matter. The task can be empty and it will result in an identical error.
All scripts ran within Visual Studio work fine.
I have looked at multiple solutions including:
Checking in your program files to see if the right version of DTExec is being used. As shown in the excerpt, I am indeed using the 150 version aka SQL Server 2019.
Most solutions on this page which include checking that the package version is the same as the currently downloaded version of SQL Server (they are both 2019 version 15) and checking the encryption type of the solution to see if the sensitive data could be at fault.
Reinstalling SSDT.
Running everything as administrator from the CMD that runs DTExec to Visual Studio 2019 which runs the code.
Rebuilding the script task.
As recommended by my senior, checking to see if DTExec was running on 32-bit or 64-bit. (If DTExec launches from Program Files(x86), it is most likely 32-bit. If it launches from Program Files, it is most likely 64-bit). It is indeed running on 64-bit.
Another recommendation was to attempt to run the package through SSMS's Agent Profiler which resulted in the same error.
Checking to see if the .Net Framework version on my computer (through checking the GAC) is the same as the target version of the package. They are both 4.8.
"C:\Program Files\Microsoft SQL Server\150\DTS\Binn\Dtexec.exe" /f "C:\Directory\Documents\SSIS Tests\TEST_PROJECT\Package.dtsx"
Microsoft (R) SQL Server Execute Package Utility
Version 15.0.2000.5 for 64-bit
Copyright (C) 2019 Microsoft. All rights reserved.
Started: 16:35:16
Error: 2022-10-20 16:35:17.17
Code: 0xC001F02A
Source: Sequence Container
Description: Cannot create a task from XML for task "Script Task", type "Microsoft.ScriptTask" due to error 0x80070057 "The parameter is incorrect.".
End Error
Error: 2022-10-20 16:35:17.17
Code: 0xC0010018
Source: Script Task
Description: Failed to load task "Script Task", type "". The contact information for this task is "".
End Error
Error: 2022-10-20 16:35:17.18
Code: 0xC0010026
Source: Script Task
Description: The task has failed to load. The contact information for this task is "".
End Error
Error: 2022-10-20 16:35:17.18
Code: 0xC0024107
Source: Script Task
Description: There were errors during task validation.
End Error
Error: 2022-10-20 16:35:17.18
Code: 0xC0010025
Source: Package
Description: The package cannot execute because it contains tasks that failed to load.
End Error
I hope this is enough information and that someone can help. Thank you.
As per AlwaysLearning's comment, the issue was with my SQL Server installation.
I hadn't downloaded SSIS when I originally installed my SQL Server instance which meant that none of my SSIS packages were running properly.

"Telemetry" task was not found

I am getting the following error when I create new .net core project on VS2017:
Error MSB4036 The "Telemetry" task was not found. Check the following:
1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the
Microsoft.Build.Framework.ITask interface. 3.) The task is correctly
declared with in the project file, or in the *.tasks files
located in the "C:\Program Files (x86)\MSBuild\12.0\bin"
directory. ConsoleApp8 C:\Program
Files\dotnet\sdk\2.1.403\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets 106
How can I solve this issue?
This error looks like you were trying to use the MSBuild version of an older Visual Studio version.
Be sure to only use dotnet commands or the MSBuild version distributed with Visual Studio or other self-contained MSBuild 15 distributions (e.g. by JetBrains).

SonarQube unrecognized command line argument c#

I'm having trouble running a scann for my c# app, I'm trying to scan a simple console application. but everytime I run my analysis I get this:
16:00:04.919 16:00:04.919 Unrecognized command line argument: /t:Rebuild
So here's the complete command since the beginning:
PS C:\Users\danie\documents\Visual Studio 2015\Projects\ConsoleApplication1> C:\SonarQube-Scanner-for-MSBuild\SonarQube.Scanner.MSBuild.exe begin /k:"ConsoleApplication1" /n:"ConsoleApplication1"/v:"1.0"
SonarQube Scanner for MSBuild 4.0.2
Default properties file was found at C:\SonarQube-Scanner-for-
MSBuild\SonarQube.Analysis.xml
Loading analysis properties from C:\SonarQube-Scanner-for-
MSBuild\SonarQube.Analysis.xml
Pre-processing started.
Preparing working directories...
16:13:12.659 Updating build integration targets...
16:13:12.674 Fetching analysis configuration settings...
16:13:13.051 Provisioning analyzer assemblies for cs...
16:13:13.052 Installing required Roslyn analyzers...
16:13:13.152 Pre-processing succeeded.
PS C:\Users\danie\documents\Visual Studio 2015\Projects\ConsoleApplication1>
C:\SonarQube-Scanner-for-MSBuild\SonarQube.Scanner.MSBuild.exe /t:Rebuild
SonarQube Scanner for MSBuild 4.0.2
Default properties file was found at C:\SonarQube-Scanner-for-
MSBuild\SonarQube.Analysis.xml
Loading analysis properties from C:\SonarQube-Scanner-for-
MSBuild\SonarQube.Analysis.xml
WARNING: Please specify the command 'begin' or 'end' to indicate whether
pre- or post-processing is required. These parameters will become mandatory
in a later release.
Pre-processing started.
Preparing working directories...
16:13:17.069 16:13:17.053 Unrecognized command line argument: /t:Rebuild
16:13:17.069 16:13:17.053 A required argument is missing: /key:[SonarQube
project key]
16:13:17.069 Expecting at least the following command line argument:
- SonarQube project key
When connecting to a SonarQube server earlier than version 6.1, the following command line arguments are also required:
- SonarQube project name
- SonarQube project version
The full path to a settings file can also be supplied. If it is not supplied, the exe will attempt to locate a default settings file in the same directory as the SonarQube Scanner for MSBuild.
Use '/?' or '/h' to see the help message.
16:13:17.084 Pre-processing failed. Exit code: 1
Any help fixing this will be appreciatted!
Thanks.
PD: I'm running sonarqube version 6.7.1 and MSBuild
The second command you execute should be just msbuild.exe, not SonarQube.Scanner.MSBuild.exe.
Edit:
The problem, is indeed that I have to execute MSBuild.exe instead of the other one but if you can't execute that, it may be because you don't haven't configured your environment varables, and path. If you can't execute it simply look for your MSBuild folder in Program Files (x86), in the end you should execute this:
'C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe' /t:Rebuild
so this should be it.

.NET, Topshelf service, Mono and different build machines

I experience a problem with running my .NET application service built with TopShelf on Mono.
The development setup is: Win 8.1, VS 2015, .NET 4.5.2 as a target framework
The CI setup: Win Server 2012, TeamCity 9.1.6, both server and build agent are running at the same machine
The execution (test server) setup: CentOS 6 x86_64, Mono 4.2.2
So I've implemented an application running as both a console application and background service (with the TopShelf) and successfully debugged and tested it locally.
I've set up the CI server in the way it builds an application on a build agent and produces as a folder with multiple dlls and .exe runner file inside (Release configuration) as a output. Finally CI publishes this folder to the remote CentOS server.
When I connect to the CentOS server via ssh and try to run it with the mono myapp.exe command, I get an error:
# mono myapp.exe
Configuration Result:
[Success] Name myapp
[Success] DisplayName myapp
[Success] Description myapp
[Success] ServiceName myapp
Topshelf v3.3.154.0, .NET Framework v4.0.30319.17020
[DEBUG][2/4/2016 7:42:57 PM][Thread 0001][EventStream] StandardOutLogger started
[INFO][2/4/2016 7:42:57 PM][Thread 0006][[akka://AkkaGrid/system/log1-NLogLogger]] NLogLogger started
[DEBUG][2/4/2016 7:42:57 PM][Thread 0001][EventStream(AkkaGrid)] Logger log1-NLogLogger [NLogLogger] started
[DEBUG][2/4/2016 7:42:57 PM][Thread 0001][EventStream(AkkaGrid)] StandardOutLogger being removed
2016-02-04 22:42:57.4509 DEBUG Start
2016-02-04 22:42:57.4538 DEBUG Logger log1-NLogLogger [NLogLogger] started
2016-02-04 22:42:57.4714 DEBUG StandardOutLogger being removed
2016-02-04 22:42:57.4714 DEBUG Default Loggers started
The myapp service is now running, press Control+C to exit.
2016-02-04 22:42:57.5075 ERROR Error while creating actor instance of type MyApp.Actors.Supervisor with 0 args: ()EXCEPTION OCCURRED:Akka.Actor.ActorInitializationException Exception during creation Void Create(System.Exception)
TypeLoadException Error while creating actor instance of type MyApp.Actors.Supervisor with 0 args: () Akka.Actor.ActorBase NewActor()
TargetInvocationException Exception has been thrown by the target of an invocation. System.Object InternalInvoke(System.Object, System.Object[])
MissingMethodException Method 'Array.Empty' not found.
2016-02-04 22:42:57.5216 INFO Message FetchEntityMessage from NoSender to akka://AkkaGrid/user/$b was not delivered. 1 dead letters encountered.
Ignoring the fact that there are also Akka.net and NLogger inside, the core issue seems to be in this line:
MissingMethodException Method 'Array.Empty' not found.
So, in order to test the compatibility of my code with Mono itself I've manually copied the application folder (Release) from my local machine (right after VS2015/MsBuild) to CentOS server and ran mono myapp.exe command again.
This way the execution succeeded and produced no errors in the output.
To ensure that the issue is not connected to the copying process, I've connected to the Win2012 server (with CI running on it), went to the build agent's working directory and executed myapp.exe as a simple windows console application. It ran successfully. Then I copied the application folder manually to the CentOS server via scp command from git bash and... got the same issue as above.
To provide some extra details, the build log is the following:
Step 2/7: Build .NET subsystem (MSBuild) (6s)
[22:36:32][Step 2/7] Starting: C:\TeamCity\buildAgent\plugins\dotnetPlugin\bin\JetBrains.BuildServer.MsBuildBootstrap.exe /workdir:C:\TeamCity\buildAgent\work\17605015421235b0 "/msbuildPath:C:\Program Files (x86)\MSBuild\14.0\bin\amd64\MSBuild.exe"
[22:36:32][Step 2/7] in directory: C:\TeamCity\buildAgent\work\17605015421235b0
[22:36:33][Step 2/7] .net\MyApp.sln.teamcity: Build target: TeamCity_Generated_Build (4s)
[22:36:33][.net\MyApp.sln.teamcity] TeamCity_Generated_Build (4s)
[22:36:33][Step 2/7] MSBuild command line parameters contain "/property:" or "/p:". It is recommended to define System Property on Build Parameters instead.
[22:36:38][Step 2/7] Process exited with code 0
So I can see that TeamCity doesn't run the MSBuild directly, but some MsBuildBootstrap application. MSBuild Tools 2015 are set in the build step settings. So... that's all the details, any help appreciated :)
MissingMethodException Method 'Array.Empty' not found.
This method is new in .NET 4.6 as specified in the documentation.
The problem is that Mono 4.2.2 is not compatible with this version of .NET.
I've looked at the sources, and it looks that Mono from the master branch already includes this. However, the commit in which it was introduced is not yet marked as being present in any tag or branch. That means you will have to wait until Mono 4.3 or 4.4 is released, or compile Mono from sources yourself, or maybe try to look for a weekly/nightly build that you could use.
An easier fix may be trying to depend on binaries that are not so bleeding edge (i.e. that were compiled using the framework version 3.5 or 4.0).

build .net application in Jenkins using MSBuild

I have a .net application built on .net framework 3.5, I am trying to build this application on Jenkins CI server. I've added MSBuild plugin and and have added path to the .exe file of 2.0, 3.5 and 4.0 versions of MSBuild. But my building processes are failing by showing the below error message.
Path To MSBuild.exe: msbuild.exe
Executing command: cmd.exe /C msbuild.exe Neo.sln && exit %%ERRORLEVEL%%
[Test project] $ cmd.exe /C msbuild.exe Neo.sln && exit %%ERRORLEVEL%%
'msbuild.exe' is not recognized as an internal or external command,
operable program or batch file.
Build step 'Build a Visual Studio project or solution using MSBuild.' marked uild as failure
Finished: FAILURE
Could anyone plz help me out..??
To make the MSBuild plugin work, you need to configure the plugin in the Jenkins management screen.
NOTE: in the newer Jenkins versions you find the MSBuild configuration in the Global Tool Configuration:
Note the "Name" field, where I've called this particular configuration v4.0.30319. You could call it anything you like, but ideally the name will somehow refer to the version.
You'll need to refer to this name later in the Jenkins PROJECT that's failing.
Note: The yellow warning implies that the Path to MSBuild field should be populated with a directory name rather than a file name. In practice you do need to enter the filename here too (ie. msbuild.exe) or the build step will fail.
In the Jenkins project that's failing, go to the MSBuild build step.
The first field in the build step is "MSBuild Version". If you created the build step before configuring any MSBuild versions, the value here will be (default).
After configuring one or more MSBuild versions, the drop down will be populated with the available configurations. Select the one you require.
You can see here that I've now selected the named configuration that matches the installation above.
Jenkins | Manage Jenkins | Configure System
scroll down to the MSBuild section and click MSBuild installations
define the full path to msbuild.exe, on my system I have 3.5 and v4.0.30319
Note - specify the path to 32-bit tools even on a 64-bit system, otherwise you might get an error message:
Building Windows Phone application using MSBuild 64 bit is not supported.
So in Jenkins - it could be for example:
Name: Version 3.5
Path: C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe
Name: Version 4.0
Path: C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSbuild.exe
I think you should set an absolute path for "msbuild.exe" in your Jenkins configuration,
for example:
C:\Windows\Microsoft.NET\Framework\v3.5\msbuild.exe
You can also add the path where the msbuild.exe is, to the PATH system environment variable of the node (or nodes) that is running that specific job.
You could try executing the
%comspec% /k ""c:\Program Files\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"" x86
command, which will temporarily update your environment path variables to reflect the VS2010 build environment. Execute this before you call MSBUILD and see what happens. I use this in my own build scripts with no issues.
Side note; it's very likely counterproductive to have multiple versions of MSBUILD on your PATH. Concentrate on getting one version working and go from there.

Categories