How to customize C# .NET Framework Manifest without Visual Studio - rider

I primarily use JetBrains Rider, which appears to lack the option to add a manifest (though my installation of Visual Studio mysteriously lacks "Application Manifest" under the "Add Item" menu anyhow).
So, I created app.manifest and filled it with the desired XML (in my case, it's a vanilla manifest with the classic <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>)... but it didn't work.
I Changed Build Action to EmbeddedResource... but it still didn't work.
I renamed the file to sandbox.exe.manifest... still nothing!
If I open the exe in a text editor, I see two manifests - mine, and the default.
What step am I missing?

You have to specify manifest file name in the project file. Open corresponding csproj file (Solution Explorer -> select your project -> F4 \ Edit sources) and add the next line to the global properties group :
<ApplicationManifest>app.manifest</ApplicationManifest>
For more information you can read this question:
How can I embed an configuration-specific manifest file in my c# app?

Related

Visual Studio 2017 VSIX with ASP.NET Core 2 Web Application template just installs a blank project

I followed the "Getting Started with the VSIX Project Template" Microsoft documentation to create an ASP.NET Core 2 Web Application template and after running the VSIX file I have the new project template listed but when I create a new project with it none of the files are there. It is just an empty project. My attempt can be found here: https://github.com/DrewBrasher/ExampleAspNetCoreTemplate
The steps in the documentation are:
Create a project template.
a. Open the project from which to create a template. This project can be of any project type.
b. On the Project menu, click Export Template. Complete the steps of the wizard. A .zip file is created in %USERPROFILE%\My Documents\Visual Studio \My Exported Templates.
Create an empty VSIX project. On the File menu, click New and then click Project. Select either Visual Basic or Visual C#. Under the selected node, select Extensibility, and then select VSIX Project.
Add the .zip file to the project. Set its Copy to Output Directory property to Copy Always.
In the Solution Explorer, double-click the source.extension.vsixmanifest file to open it in the VSIX Manifest Designer, and then make the following changes:
Set the Product Name field to My Project Template.
Set the Product ID field to MyProjectTemplate - 1.
Set the Author field to Fabrikam.
Set the Description field to My project template.
In the Assets section, add a Microsoft.VisualStudio.ProjectTemplate type and set its path to the name of the .zip file.
Save and close the source.extension.vsixmanifest file.
Build the project.
In the output directory, double-click the .vsix file.
A VSIX Installer message box appears. Follow the instructions to install the extension.
Close Visual Studio and then re-open it.
I believe this is a Visual Studio bug but I have found a workaround. After exporting the project as a template (step 1b), you need to:
Extract the zip file.
Add this to the "TemplateData" section of the .vstemplate file:
<CreateInPlace>true</CreateInPlace>
Compress the files back into a zip file.
Continue with the rest of the documentation.
Sources:
https://developercommunity.visualstudio.com/content/problem/21751/creating-new-project-from-vs-2017-rc-exported-temp-1.html
Exported project template in VS2017 misses source files

Build error when signing with snk key

Build error is occurring since using Visual Studio 2015. When building in Visual Studio 2015 this is occurring rarely. When building in TeamCity this occurs very often.
[Error in Visual Studio 2015]
Error extracting public key from file 'CompanyName.snk': The process cannot access the file 'C:\Users\UserName\AppData\Local\Temp\tmp2FF6.tmp' because it is being used by another process. CompanyName.Project.DAL D:\Projecten\CompanyName\Repository\Source\Components\CompanyName.Project.DAL\vbc
http://i.stack.imgur.com/hKbbe.png
[Error in TeamCity]
CSC error CS7027: Error signing output with public key from file 'CompanyName.snk' -- The process cannot access the file 'C:\BuildAgents\Gamma\temp\buildTmp\tmpD91D.tmp' because it is being used by another process.
http://i.stack.imgur.com/rbgHx.png
I know it's been a while since this was asked but as I use SO for my own reference and I had this problem too I wanted to share my solution.
.snk files are for signing a project. You might need to make a new one.
Right click on your project, select properties.
Click on Signing.
Click the checkbox beside "Sign the assembly".
On the dropdown labelled "Choose a strong name key file" click new.
Fill in the dialog box as you wish noting particularly the Key file name. When you press ok, this will generate a new .snk file.
Save the project and rebuild.
This will use the new .snk in your project and will resolve the
error.
Hope this helps.
Try to clean up the temp folder that is used by the build.
I have seen different types of problems when the temp folder has lots of files.
Some of the tools are using GetTempFileName and they will get errors when temp has a lots of files
The GetTempFileName method will raise an IOException if it is used to create more than 65535 files without deleting previous temporary files.
This is probably an instance of this issue with Roslyn compiler. The workaround would be adding
<UseSharedCompilation>False</UseSharedCompilation>
under any <PropertyGroup> node in .csproj file.
It started for me when I moved the Resharper Cache to System Temp. When I moved it back to the Solution folder, the problem went away, and I could build again.
I just had the same problem. In Visual Studio 2015, I fixed it using the following steps:
Go to Tools > Options
From the Options dialog, select "Projects and Solutions > Build and Run"
Set the "maximum number of parallel project builds" to 1
+1 to #stukselbax for getting me on the right track
Also got help from this link
I used '/m:1' as an msbuild argument, and 'SignPublic' property to true in the csproj file.
Just had this issue today in visual Studio 2022- I was messing with the csproj file and ended up having the wrong filepath to the snk file. I fixed it by changing the filepath to be correct.
Right-click on the project -> unload (so that you can edit the csproj file)
Under <PropertyGroup> check the <AssemblyOriginatorKeyFile> tag
My code was:<SignAssembly>true</SignAssembly> <AssemblyOriginatorKeyFile>../NAMEHERE.snk</AssemblyOriginatorKeyFile> NAMEHERE was specific to my project, yours will vary. Look at your snk file. The ../ in front will vary, check the filepath of your snk file. If you caused this error by messing with your csproj file, like I did, then the correct answer is what the filepath was before you changed it. :)
Right-click on the project -> reload

Include vb.net modules in compilation

I have created a program in vb.net using Visual Studio Express 2013, and I compile it there, it works fine except the modules. It doesn't include mysql.data (which is essential to the application). How do I include these modules in the compilation? (I already tried putting the .dll in the solution explorer.)
All you need to do, is to include the file in the project by: Right-Click on solution > Add file.
Once done, set “Build Action” to “Content” and its “Copy to Output Directory” mode to “Copy if newer” from the properties window.
Go to Add Reference and Add .DLL file reference using browse option.

Specify output executable name for burn bootstrapper

In VS2012 I created a WIX Bootstrapper project (BURN). I named the project "Bootstrapper". Now the bootstrapper works fine, but I would like to change the name of the generated file (bootstrapper.exe) in something different. I am unable to find where this outputfile name is set.
Well, you can also do it from within VS 2012:
In Solution Explorer, right click on your Bootstrapper Project and from Context menu, click on Properties:
This should open the Properties page for your Project. You can change the output file name (and output type as well) of your Bootstrapper project
Update: Here is the screenshot of dialog:
Regards
I found the answer myself. In Visual studio unload the project and change the OutputName element in the xml.

How to create a uninstall command for a Windows-based application in the Application Folder

Can anyone explain to me how to create a uninstall command for a Windows-based application in the Application Folder when creating a new setup project in visual studio 2008.
I've found info on the net but nothing helping me so far. If you could supply me with links or instructions it would be great.
Thanks.
In Visual Studio.NET:
File > Add Project > New Project > Setup & Deployment Project > Setup Project
(Enter name and location)
Add (right-click in Application Folder > Add > Project Output):
Primary Output
If an error occurs about files that should be excluded > In Solution Explorer select your Setup project > Exclude those files (right-click > exclude)
Build > Build ’name project’
In Windows:
Create an Uninstall.bat file containing:
C:\WINDOWS\system32\MsiExec.exe /I{productcode}
(Path depends of your Windows version, check where your system32 folder is located)
(You’ll find the productcode in Visual Studio.NET > Tab Properties in the setup project you’ve just created)
Open the setup project in Visual Studio.NET if you closed it
Add (right-click in Application Folder):
Add > Project Output > File > Uninstall.bat
Create New Shortcut > Application Folder > Primary Output (enter a name)
Create New Shortcut > Application Folder > Uninstall.bat (enter a name)
Add > File > add .ico files you want to use for the shortcuts
Shortcuts properties > ‘icon’ property (use the icons you’ve just added)
Move the shortcuts to User’s Desktop/User’s Programs Menu (you can also create subfolders)
Build > Rebuild ’name project’
The setup is ready now. You can install via Setup.exe (default it’s located under the folder ‘Debug’, you can change it in Visual Studio.NET - right-click your setup project > properties > Output file name). The shortcuts will be added automatically in the coresponding folders (desktop/start menu).
You can uninstall the program via Uninstall.bat (or via shortcut naar Uninstall.bat)
The command line for uninstalling using msiexec :
msiexec /uninstall {GUID}
{GUID} is the Product Code of the setup package and you can find that in your Setup Project Properties.
The uninstall program can be as simple as a bacth with that command or maybe a separate application, executing the command and performing addional custom cleaning.
L.E. Also, here is Microsoft's online documentation for msiexec.
L.E. Good article giving code snippet for creating a C# application that performs the uninstall
It's much easier is to just add an uninstall shortcut with arguments directly to the setup project instead of creating a batch file or adding code to the main() sub or start form. This should work for any .net language using Visual Studio. I have it working for VB .net using VS2008 for several projects. Here's how:
Go to the file system definitions in the setup project. Right click in the folders section (left pane) and add special folder - System Folder.
Select the newly added System Folder in the left pane, and in the right hand pane, right click and select "add file."
Add the file msiexec.exe that is in your system32 folder (Most likely c:\windows\system32)
Go back to the left pane and drill down in the User's Programs Menu folder to the folder you want to hold the uninstall shortcut. Select it.
In the right pane right click and select "create new shortcut." In the dialog box, click on System Folder and then the msiexec.exe file. Click OK and then rename the shortcut to whatever you want like "Uninstall MyProgram."
Right click on the new shortcut and select "properties window."
In the properties window, in the arguments variable type /x [ProductCode] (there is a space between the /x and [ProductCode] You can use other switches instead of /x, if you want - check out the available switches for msiecec.exe.
That's it. Now when you run the setup project it will add a shortcut to your user's program menu to uninstall the program. One other comment, on the compile you will get a warning that msiexec.exe should be excluded because its source file is under Windows System File Protection. Just ignore this warning.
i too don't know how to find this elusive product code, but to answer your other question on removing the folder I found this document that may help you out
http://www.codeproject.com/KB/install/NET_Uninstaller.aspx
You can get this product code from your application setup project in properties window of
your
setup project
. [Select project node in Solution Explorer and click F4 and copy the Product code.]
This looks similar to ... {21F66170-1C81-40E1-AB96-3303FF098425}