NET6 Linux-x64 Self-Contained Single-File Unusable - .net-6.0

I've a project that runs perfectly as "Framework-Dependent Single-File" on Linux-x64, and also as a "Self-Contained" application.
But when I compile as "Self-Contained Single-File", the Visual Studio 2022 (17.1.2) creates a file without any extension (exe or dll), and I cannot run it anyway on Ubuntu 21.x.
When I call it, I always get an "invalid application" error. I tried:
dotnet myproject
dotnet myproject.dll (adding the DLL extension manually before the call)
dotnet myproject.exe (adding the EXE extension manually before the call)
Is there something I could be doing wrong?
I appreciate any help you can provide.

As Heretic Monkey stated, you need to run it with ./NAME
Also you need to make sure that the user has Execute permissions for that file. See chown/chmod

Related

Publish to AWS Lamba - Failed to find the "build-lambda-zip" utility

I'm currently trying to publish my AWS lambda functions using Visual Studio 2019 community (v4.8.03752) and leveraging the AWS Toolkit for Visual Studio (v1.20.1.0). After right clicking my project and selecting 'Publish to AWS Lambda' I receive the following error:
- Zipping publish folder C:\Users\Matt\source\repos\programName\programName\.\bin\Release\netcoreapp3.1\publish to C:\Users\Matt\AppData\Local\Temp\HelloWorld-CodeUri-Or-ImageUri-637489827969959200.zip
- Failed to find the "build-lambda-zip" utility. This program is required to maintain Linux file permissions in the zip archive.
- Error packaging up project in C:\Users\Matt\source\repos\programName\programName\. for CloudFormation resource HelloWorld: Failed to find the "build-lambda-zip" utility. This program is required to maintain Linux file permissions in the zip archive.
I've been able to deploy this MANY times over previous months, up until Friday 2/12 when I started receiving this error (after a reboot). What's even more strange is that if I uninstall the AWS Toolkit for VS, then reinstall it, I'm able to publish successfully 1 time. With my 2nd attempt, I begin to receive this error again.
Steps I've taken to attempt to resolve:
Repair Visual Studio
Uninstall/Reinstall Visual Studio
Uninstall and reinstall amazon.lambda.tools using dotnet tool install -g Amazon.Lambda.Tools
Uninstall AWS Toolkit for VS, Reinstall toolkit. (This works for first deployment, fails when trying to deploy a 2nd time)
UPDATE:
Per some comments below, it looks like this is being caused by McAfee Real-Time Scanning. In checking the logs during a deployment I noticed a "Virus or threat found" record that points directly to the build-lambda-zip.exe file. To permanently avoid this issue moving forward please follow the steps provided by user2174794 in the comments below.
I'm having the same issue. Just started happening today. It was working within the last 2 weeks.
Failed to find the "build-lambda-zip" utility. This program is required to maintain Linux file permissions in the zip archive.
Running Windows 10, Visual Studio 2019
My solution for now is to use the .NET Core CLI
https://docs.aws.amazon.com/toolkit-for-visual-studio/latest/user-guide/lambda-cli-publish.html
Specifically, the
dotnet lambda deploy-function
A recent update must have broke the AWS Toolkit For Visual Studio.
I have the same problem, it was because my antivirus detect the executable build-lambda-zip.exe, then delete it.
I restore the executable from my antivirus, or restore dotnet tools with the command :
dotnet tool update -g Amazon.Lambda.Tools
I also faced the same issue,
This is because the "build-lambda-zip.exe" file is getting removed by the McAfee Antivirus.
For the permanent fix, you need to follow the below steps.
Step 1
Go to McAfee Settings >> Quarantined Items
You will find the "build-lambda-zip.exe" file there. Restore it to the original location.
Now If you will try to publish, the error won't get displayed. But again on the next scan, the file will get removed.
Step 2
We need to Exclude this file from getting Scanned and removed. So for that,
Go to McAfee Settings >> Real-Time Scanning and Add the "build-lambda-zip.exe" file in the Excluded files list.
For the file path of "build-lambda-zip.exe" got to
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\Extensions\ and search for the file name.
Maybe you should try reinstalling the AWS Tool Kit and before you make deployments please turn off your antivirus protection. I was troubbling the same issue and my antivirus(McAfee) was deleting build-lambda-zip.exe file when I did deployment first time.
I'm curious about the state of the extension installation. Can you go to VS's extension directory in Windows explorer C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\Extensions and in the search box search for AWSToolkitPackage.dll.
Ideally it should only show one instance of that file. Assuming it finds a single instance right click on the file and select "Open File Location". Now that you are in the root folder of the AWS extension check the Resources folder and see if it contains the file build-lambda-zip.exe.
I know the question is in a windows system, but under a linux system, in my case the following command was needed:
sudo apt-get -y install zip

MSVCP120.dll missing

I compiled and linked an executable file in VS2013, and then tried to run that exe on another computer.
I get this error on the other computer:
I read on this problem, and I saw I need to download VS2013 on the other computer to be able to execute this file.
But what is the point in exe file if I need to download a VS2013 on any computer I want to run it on?
Is there any normal way to execute it through the visual without go through this problem?
The MSVCP120.dll is part of the Visual C++ 2013 Redistributable package. Download and install it on the other PCs to get the program working or link the required lib via static linking.

Run install.ps1 when NOT installing in VisualStudio

I am looking for a way to execute a script when a nuget-Package is installed, but not in a VS solution or project.
I tried to include a install.ps1 in the tools folder, but it does not execute.
I thought it might be because I do not have any files in lib or content. So I included some dummy file into /content but it still does not execute.
So i changed it to an init.ps1 just to check but it still does not execute.
Now my guess is: the *.ps1 scripts only execute if I install the package into a VS solution/project. Is this correct? I did not find anything in regard in the documentation.
I am trying to install my package in a plain folder. No projects, no solutions, no VS.
Is there a way to make nuget execute any script in my case?
If you read the documentation here (Automatically Running PowerShell Scripts ) it mentions that those scripts are run in the context of a project or solution.
Most often install/uninstall action is add/remove references or files to/from the target project, so it actually makes no sence to run those without project context.

How to delete installation directory when program is uninstalled by visual studio installer project?

I have created an installer using visual studio 2010 installer project. The program installs correctly and works fine for all the features.
But the problem is in uninstallation, when I uninstall the program it does not delete the application directory from file system but deletes the contents of it.
Suppose I am installing the program in C:\Program Files\MyApp, it deletes the contents of MyApp folder but doesn't delete the folder it self.
Any way to do this? If there is a way then how to do this?
Does your application create files in this directory after it's been installed? If so, you might want your app to move that user-data to a more user-data-centric location like %PROGRAMDATA% so that application files and user-data are separated.
It also helps to make sure uninstall cleans up everything, and it's easier to persist user-data across upgrades.
Relevant thread - http://www.itninja.com/question/delete-folders-after-uninstall

CMAKE does not create INSTALL project in Visual Studio

I am trying to compile a Library using CMAKE-gui 3.0.2 and Visual Studio express 2013.
Everything seems to be fine during the configuration/generation process in cmake-gui, as I am able to set the CMAKE_INSTALL_PREFIX variable to the path in which I want to have my library installed. And I got no errors during configuration and generation.
I then open the generated .sln file in which I can build the ALL_BUILD target, which runs smoothly with no errors and no targets skipped.
However, the INSTALL target is simply not present in the Solution Explorer, therefore I really do not have any idea on how to install the library.
Upon further inspection, I noticed that cmake did create a file called cmake_install.cmake, but I don't know what should I do with it.
CMake will only generate the INSTALL target when there is actually anything to install. It would seem you have no install() commands in your project.
Presence of the variable CMAKE_INSTALL_PREFIX does not imply anything - the variable is always present, and is used to control the installation destination when there is anything to install.
Likewise, the file cmake_install.cmake is always created; but if you inspect it, you'll find it's basically a no-op in your case (probably just some messages, setting CMake variables and possibly creating a manifest which is not used for anything).

Resources