Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

common Settings.settings file for entire solution

Is there a way to have common Properties file for all the projects of the solution?

I have a console application and bunch of other class librarry files and i want to have only one Settings file for them.

I am not talking about app.Config file. I am talking about Settings.settings file.

Any idea how i can do it?

Also is it a good practice to store configuration settings in the Settings file rather than app.config?

like image 770
Asdfg Avatar asked Apr 26 '11 15:04

Asdfg


People also ask

What settings settings file?

A settings file can be used to store settings or configuration information for a software application or operating system. It can be used to store configuration information, state of variables, defaults, preferences, and other details.

Where are configuration settings stored?

Machine configuration files The machine configuration file, Machine. config, contains settings that apply to an entire computer. This file is located in the %runtime install path%\Config directory. Machine.

What is settings file in C#?

settings file that the project system creates; this file is the default file that the Project Designer displays in the Settings tab. Settings. settings is located in the My Project folder for Visual Basic projects and in the Properties folder for Visual C# projects.

How do I create a settings file in Visual Studio?

In Visual Studio, from the Project menu, choose Add New Item. The Add New Item dialog box opens. In the Add New Item dialog box, select Settings File, enter a name for the file, and click Add to add a new settings file to your solution. In Solution Explorer, drag the new Settings file into the Properties folder.


1 Answers

Place the file you want to share across projects in a Solution Folder. Then, in each project, choose to Add Existing Item ..

In the Add Existing Item dialog, choose the common file. Instead of clicking the Add button, click the drop-down arrow on the right side of the Add button and choose Add As Link from the drop-down menu.

Add As Link

If this is for a Settings file, you need to set the Custom Tool property for the file:

file properties

If your file is Settings.settings you can open your project properties and go to the Settings tab and Visual Studio will set this Custom Tool property for you automatically.

Once the Custom Tool is set, you will see a Designer.cs file created underneath your settings file. This Designer.cs file contains generated code to make your settings accessible programatically.

Designer sub-file

As you can see, the Designer.cs file is also a linked file, and it's physical location will be the same as your settings file.

like image 130
quentin-starin Avatar answered Sep 22 '22 02:09

quentin-starin