How generate edmx resources of my Entity Framework project? - c#

I want to compile my c# project with roslyn and I need to generate resources files with resgen
resgen /compile Resources.resx
and then I get all *.resources file from my projects and embed to assembleis
myCompilationOfProject.Emit(ms,manifestResources : ListOfResources);
but I have a project with EDMX file and find out that I must some resources that there is in this project ( *.csdl,*.msl,*.ssdl that is in myDatabaseProject\Debug\obj\edmxResourcesToEmbed folder ) .Visual studio embedded these files I saw these files with a reflector. I added these files to my compiled project with roslyn and it works well.
I want to khow how visual studio generat theses file and from which file and which tools ? I would generate these resources file programmatically in my c# code

Related

Exclude certain files from compiling in directory

I am trying to create multi file assembly by creating .netmodules for respective Visual Studio projects. These .netmodules are being created successfully. Command used to produce the modules:
csc.exe "/out:$(ProjectDir)$(ProjectName).netmodule" "/t:module" "/recurse:$(ProjectDir)*.cs"
The problem with the above command is the switch :/recurse:$(ProjectDir)*.cs, which compiles all files in the project including AssemblyInfo.cs file. This file is compiled for each project.
At the end when I am trying to build a multi file assembly using following command:
csc.exe /t:library /out:MultiFile.dll /addmodule:Foo.netmodule /addmodule:Boo.netmodule
I get the error error CS7061: Duplicate 'GuidAttribute' attribute in 'Foo.netmodule'
Please state any ways to create multi file assembly.
As of me, I can think of two ways, deleting the AssemblyInfo.cs files from project or find a way to exclude the specific files from compiling in the /recurse switch (don't know how to exclude the file).
Although it would be nice to pass some parameter to CSC.exe to exclude some files from /recurse switch. I did not find it anywhere.
Solution I opted for:
Copy all source files for each Visual Studio project to different folder, excluding the AssemblyInfo.cs file.
Compile all the files from that folder to produce .netmodule.

visual studio generates executable from C# but where are the obj files?

I have Visual Studio Express 2010 installed, and have used it for a C# project.
Now I am writing a .gitignore file so I can exclude from git the object files that I expect to be generated.
I come from a C++ world mainly.
Trouble is, despite the fact that the target is being generated correctly I cant see any object files (with .obj or .o extension)anywhere in the directory tree of the solution.
Could this be caused by the configuration where they are being sent elsewhere?
To answer your direct question: C# doesn't have a compile step that produces .obj files like C and C++ do.
However, a .gitignore that's appropriate for C# projects is a well-solved problem. Visual Studio will ask you if you want to add the .gitignore to your new git repository when you create it. If you already have a repository, you can just use the community's .gitignore for Visual Studio which is excellent (and what Visual Studio would install for you.)
There aren't any .obj files generated during compilation, but there is an obj directory under the project root that's used to store temporary files. This is the directory that should be in your .gitignore file.

Compile resx files in the project or just use resgen without compiling resx

I am using 2 resx files in my project one for en-Us and other for de-DE (localization).
I compile these resx files to resource files using resgen.
Can anyone please help me on the following two questions:
If I need to add more resx files in the project say for fr-FR, would I need to compile the project again after adding he new resx file for fr-Fr in the project or can I just create the resx file and generate the .resources file from the resx using resgen tool without compiling the Visula studio project?
Can the .resource file generated from resx using resgen be embedded in the exe or would it remain as a standalone compiled binary alongwith the exe that uses the resources file?
AFAIK
1 - You can re-create new .resource file and just replace the old one
2 - You have to deploy resource files along with your assemblies
see more here http://msdn.microsoft.com/en-us/library/21a15yht.aspx

What has replaced the VERSIONINFO resource for C# projects?

C# projects use a .resx file for resources. This is fine for strings, but it does not seem to have the equivilant of the old VERSIONINFO resource that the C++ project .rc files supported.
I can not believe that Microsoft has given up the idea of keeping track of executable versions ... so is there some VERSIONINFO-equivilent resource used with the .resx resource file? How do you bind version information into a C# project?
If you select a project in the Visual Studio Solution Explorer, right-click Project/Properties, and click the Assembly Information button, you can put your version information in the dialog box that opens.
The version information is stored in the resulting assembly's manifest.

How to embed .tlb as a resource file into .NET Assembly DLL?

We're using our .NET Assembly DLL within native C++ through COM (CCW).
Whenever I make new version of my DLL, I have to send two files (.dll and corresponding .tlb) to crew that's using it in their code.
Is it possible to embed .tlb file as a resource in .NET DLL file?
It is not exactly straightforward to do this with Visual Studio .NET, but it can be done. At a basic level, what you have to do is this:
Generate your TLB file, e.g., "YourLibrary.tlb".
Create a Win32 resource script file called, for example, "YourLibrary.rc" using a text editor (such as Notepad, or File/New/File.../Text File in Visual Studio).
In the script file, type the following text verbatim (but substitute your actual TLB file name of course):
1 typelib "YourLibrary.tlb"
Save the script file to the same folder as the TLB file.
From a Visual Studio Command Prompt, change to the folder with the script file and compile it using the following command:
rc YourLibrary.rc
This will generate a Win32 resource file in the same folder called "YourLibrary.res".
In Visual Studio, right click the project node (e.g., "YourLibrary") in the Solution Explorer and select Properties.
On the Application tab, under "Resources", select the "Resource File" option and browse to the "YourLibrary.res" file from step 5.
Save and rebuild the project.
The TLB will now be embedded as a resource in the DLL such that other COM applications can read it.
If you regenerate the TLB file later you will need to repeat step 5 to recompile the resource file, and step 8 to embed the new version in the DLL.
All that said, you may be able to automate some of this with Build Events or by putting custom MSBuild targets into your project file, but that is a whole other discussion.

Categories