So, here is what I am trying to do.
I am trying to stamp name of the user who compiled the particular project. As link assembly version is there any way by using that I can store the original user name on dll.
I tried creating custom attribute and using it in AssemblyInfo.cs, but it gives me the username of person who is running the dll and not who build it.
Any help will be appreciated.
For modifying the Assembly info I use a pre-build event that executes a batch file for the modification.
You could write a custom MSBuild action that updates an assembly attribute in a known file prior to compilation. This has the downside of having to install the custom build step on all dev machines and any build machines.
So here is I found I am trying trick.
I have created new custom attribute AssemblyCompiler. And by changing and using powershell script shown here . Seems it works.
Another C# solution
Create new custom attribute
write c# program to update/add username
call that c# code on prebuild event as follows
call ....\Resources\OverwriteAssemblyInfo.exe [ I placed my the executable file in resources]
Related
I've been getting into C# item and project templates.
I followed Microsoft's documentation on how to make a custom Wizard, but whenever I try to use the item template that I have made, I run into an error.
https://learn.microsoft.com/en-us/visualstudio/extensibility/how-to-use-wizards-with-project-templates?view=vs-2019
The item template works, when I don't reference the WizardExtension tags in the vstemplate of the template, but that defeats my whole point of using tags and a wizard for pre-written code.
Could someone help me figure out why that is? I will include the files in case someone wants to try it for themselves or even help to correct them.
Thanks in advance!
Your wizard assembly is not strong-named. If you strong-name the assembly, and use the fullname of the assembly in your tag, I suspect that'll fix you up.
I wrote a blog entry that was subsequently archived detailing how to do this, which is now located at :
Creating a VSIX Deployable Project (or Item) Template with Custom Wizard Support
The first time you build the signed assembly, you'll need to retrieve it's PublicTokenKey, to fix up the tag in your .vstemplate. The following article shows how to add a custom tool to your Tools menu to easily retrieve that token string:
How to: Create a Tool to Get the Public Key of an Assembly
Also, you don't need that Package.cs file. But if you remove it, be sure you set the project's "Generate .pkgdef File" property to false, so you don't get a build error trying to generate a .pkgdef, and remove the corresponding Package asset from your .vsixmanifest.
I created a managed code custom action handler library using C#. I tried localizing the DLL, but the default behavior of the Wix.CA.targets execution is to NOT include the language resource DLLs (in their subdirectory structure) in the packaging of the unmanaged code wrapper, thus, I cannot make use of the C# localization.
I really don't wish to put these string in as properties in the MSI, and read them in the custom action handler. This seems clunky, and, for deferred custom actions, unwieldly. I would much prefer to include the localization directly in the custom action handler DLL.
Can anyone tell me how to alter the Wix.CA.targets file to include these language resource DLLs in the packaging so that I can localize successfully? Or, is it simpler than that - for instance, is there some project property or registry entry I can set?
Thanks in advance.
You need to add post-build event to your CA project. That event should make C# DTF using local .NET culture folder and .resources files for translations with MakeSFxCA.exe. More details - here and here. An example of commands which I used: "%wix%SDK\MakeSfxCA.exe"
"$(TargetDir)CustomActionUtilities.CA.dll" "%wix%SDK\x86\sfxca.dll"
"$(TargetDir)CustomActionUtilities.dll"
"$(TargetDir)Microsoft.Deployment.WindowsInstaller.dll"
"$(TargetDir)CustomAction.config"
"ru-RU\CustomActionUtilities.resources.dll=$(TargetDir)ru-RU\CustomActionUtilities.resources.dll"
"C:\Users\Vitaly-work\Documents\Visual Studio
2010\Projects\ActivationKeys\CryptoLibrary\bin\Release\CryptoLibrary.dll"
"C:\Users\Vitaly-work\Documents\Visual Studio
2010\Projects\ActivationKeys\packages\BouncyCastle-Ext.1.7.0\lib\net20\BouncyCastle.CryptoExt.dll"
Note that quotation marks are important for correct handling of the commands by VS.
In property dialog for a single c++ file, I could see the command to compile the the single c++ file.
But for c# project, I could not even compile a single cs file. Are there any means to know what's the exact command line used in VS to produce the final assembly?
First thing I would like to declare is you are able to compile a single C# code, but you need to put the code to a separate project, or build it via command line, see here: How to compile just one file in c#?
For your second question, it seems you are unable to access or modify the command used in VS to compile C# code. However, you could check all your building options via Property (right click on your project name)->Build, and specify your customized pre and post building events on Property->Build Event.
As the last resort, turn on MSBuild logging to see some building details. You can refer to this page and this page.
I'm using Closure Compiler in my application. For the moment, I use XML to send my javascript to the CC's web service and compile the code. What I want to do is include CC into the project itself so that the compilation doesn't rely on the web service but is done entirely on the server. How do you include the .jar files that are downloaded in the CC download package and make it work in .net?
Thanks.
The simplest solution is just to put the CC folder on that server and then add it's path to your $PATH. Another option is to add it as a resource in the project and then set Copy to Output Dir to Always or If Newer and use a relative path to access it. I believe the second option is better because it removes the outside dependency.
Once you have the file there you can start a command line process with the commands like they have in the docs java -jar compiler.jar --js hello.js --js_output_file hello-compiled.js and it will do what you want. There is of course also a Java dependency. For some basic info on starting process' in C# check out http://msdn.microsoft.com/en-us/library/system.diagnostics.process(v=vs.110).aspx
The problem isn't much more than the title I'm afraid.
I have a Visual Studio 2010 solution that many people work on and and deploy and I need to add the details of the person who compiled that particular version of the assembly to the AssemblyInfo.cs file, more specifically the AssemblyDescription attribute.
Any ideas as how to do this?
Add a Pre-build event which rewrites the AssemblyInfo.cs file.
You could even add a second file named PersonDetails.cs which you don't put in source control (i.e. into the ignore list) in which you only put the persons details.
The build event would be a small application you write which gets the user name from e.g. the Windows credentials and puts it in the C# file.