Dot Net Apps On Mac

-->

Jun 23, 2016  In my previous blog post I have written about running your first dotnet app in a MAC machine. In this post, we will see how we can debug the same app using VSCode Editor. To start debugging your app, we need to have two files configured in the project Launch.json - maintains the debugging session's launching configurations and other.

By Rick Anderson, Kirk Larkin, Daniel Roth, and Scott Addie

Inexpensive genogram software for mac free. Genogram free download - Free Genogram Maker, GenoPro 2011, iGenogram, and many more programs. Apr 18, 2019  An application or software that is used to create genogram (family diagram) is known as Genogram Maker. The technology experts have developed Genogram Maker Software for Mac, iOS device(s), Windows, Linux, Ubuntu, Android and other operating systems. Some genogram maker software are especially designed for Mac OS. GenoProX Expert. Has all the new enhanced versatility of GenoProX Family and adds the Genogram capabilities, great for advanced genealogists, academia, therapists, social workers, communities, child adoption services, and hospitals. Combine the Health journal with GenoShare and you now have a complete Family Health history that can be shared and prepare you to live the best possible future. Apr 17, 2019  Genogram-Maker Apps For Mac. To create genogram, it is must to have a useful software which can be used to develop a highly specific type of diagrams, symbols, and genogram templates. How to make a Genogram on Mac? Here are best 3 Genogram Maker For Mac which are loaded with features and can create smooth, interactive and detailed genograms. Is there a Mac version of GenoPro? GenoProX will be a MacOS native app, however it is still in development stage. However, you can run GenoPro 2020 on your Mac.GenoPro 2020 is a Windows platform application, but it will run on your Mac with the help of special software such as CrossOver, Parallels or VMFusion.

View or download sample code (how to download)

This document explains techniques for storing and retrieving sensitive data during development of an ASP.NET Core app on a development machine. Never store passwords or other sensitive data in source code. Production secrets shouldn't be used for development or test. Secrets shouldn't be deployed with the app. Instead, secrets should be made available in the production environment through a controlled means like environment variables, Azure Key Vault, etc. You can store and protect Azure test and production secrets with the Azure Key Vault configuration provider.

Environment variables

Environment variables are used to avoid storage of app secrets in code or in local configuration files. Environment variables override configuration values for all previously specified configuration sources.

Consider an ASP.NET Core web app in which Individual User Accounts security is enabled. A default database connection string is included in the project's appsettings.json file with the key DefaultConnection. The default connection string is for LocalDB, which runs in user mode and doesn't require a password. During app deployment, the DefaultConnection key value can be overridden with an environment variable's value. The environment variable may store the complete connection string with sensitive credentials.

Warning

Environment variables are generally stored in plain, unencrypted text. If the machine or process is compromised, environment variables can be accessed by untrusted parties. Additional measures to prevent disclosure of user secrets may be required.

The : separator doesn't work with environment variable hierarchical keys on all platforms. __, the double underscore, is:

  • Supported by all platforms. For example, the : separator is not supported by Bash, but __ is.
  • Automatically replaced by a :

Secret Manager

The Secret Manager tool stores sensitive data during the development of an ASP.NET Core project. In this context, a piece of sensitive data is an app secret. App secrets are stored in a separate location from the project tree. The app secrets are associated with a specific project or shared across several projects. The app secrets aren't checked into source control.

Warning

The Secret Manager tool doesn't encrypt the stored secrets and shouldn't be treated as a trusted store. It's for development purposes only. The keys and values are stored in a JSON configuration file in the user profile directory.

How the Secret Manager tool works

The Secret Manager tool abstracts away the implementation details, such as where and how the values are stored. You can use the tool without knowing these implementation details. The values are stored in a JSON configuration file in a system-protected user profile folder on the local machine:

File system path:

%APPDATA%MicrosoftUserSecrets<user_secrets_id>secrets.json

File system path:

~/.microsoft/usersecrets/<user_secrets_id>/secrets.json

In the preceding file paths, replace <user_secrets_id> with the UserSecretsId value specified in the .csproj file.

Don't write code that depends on the location or format of data saved with the Secret Manager tool. These implementation details may change. For example, the secret values aren't encrypted, but could be in the future.

Enable secret storage

The Secret Manager tool operates on project-specific configuration settings stored in your user profile.

The Secret Manager tool includes an init command in .NET Core SDK 3.0.100 or later. To use user secrets, run the following command in the project directory:

The preceding command adds a UserSecretsId element within a PropertyGroup of the .csproj file. By default, the inner text of UserSecretsId is a GUID. The inner text is arbitrary, but is unique to the project.

In Visual Studio, right-click the project in Solution Explorer, and select Manage User Secrets from the context menu. This gesture adds a UserSecretsId element, populated with a GUID, to the .csproj file.

Set a secret

Define an app secret consisting of a key and its value. The secret is associated with the project's UserSecretsId value. For example, run the following command from the directory in which the .csproj file exists:

In the preceding example, the colon denotes that Movies is an object literal with a ServiceApiKey property.

The Secret Manager tool can be used from other directories too. Use the --project option to supply the file system path at which the .csproj file exists. For example:

JSON structure flattening in Visual Studio

Visual Studio's Manage User Secrets gesture opens a secrets.json file in the text editor. Replace the contents of secrets.json with the key-value pairs to be stored. For example:

The JSON structure is flattened after modifications via dotnet user-secrets remove or dotnet user-secrets set. For example, running dotnet user-secrets remove 'Movies:ConnectionString' collapses the Movies object literal. The modified file resembles the following:

Set multiple secrets

A batch of secrets can be set by piping JSON to the set command. In the following example, the input.json file's contents are piped to the set command.

Open a command shell, and execute the following command:

Open a command shell, and execute the following command:

Access a secret

The ASP.NET Core Configuration API provides access to Secret Manager secrets.

The user secrets configuration source is automatically added in development mode when the project calls CreateDefaultBuilder to initialize a new instance of the host with preconfigured defaults. CreateDefaultBuilder calls AddUserSecrets when the EnvironmentName is Development:

When CreateDefaultBuilder isn't called, add the user secrets configuration source explicitly by calling AddUserSecrets. Call AddUserSecrets only when the app runs in the Development environment, as shown in the following example:

Dot net apps on mac computer

User secrets can be retrieved via the Configuration API:

Map secrets to a POCO

Mapping an entire object literal to a POCO (a simple .NET class with properties) is useful for aggregating related properties.

Assume the app's secrets.json file contains the following two secrets:

To map the preceding secrets to a POCO, use the Configuration API's object graph binding feature. The following code binds to a custom MovieSettings POCO and accesses the ServiceApiKey property value:

The Movies:ConnectionString and Movies:ServiceApiKey secrets are mapped to the respective properties in MovieSettings:

String replacement with secrets

Storing passwords in plain text is insecure. For example, a database connection string stored in appsettings.json may include a password for the specified user:

A more secure approach is to store the password as a secret. For example:

Remove the Password key-value pair from the connection string in appsettings.json. For example:

The secret's value can be set on a SqlConnectionStringBuilder object's Password property to complete the connection string:

List the secrets

Assume the app's secrets.json file contains the following two secrets:

Run the following command from the directory in which the .csproj file exists:

The following output appears:

In the preceding example, a colon in the key names denotes the object hierarchy within secrets.json.

Remove a single secret

Assume the app's secrets.json file contains the following two secrets:

Run the following command from the directory in which the .csproj file exists:

The app's secrets.json file was modified to remove the key-value pair associated with the MoviesConnectionString key:

dotnet user-secrets list displays the following message:

Remove all secrets

Assume the app's secrets.json file contains the following two secrets:

Run the following command from the directory in which the .csproj file exists:

All user secrets for the app have been deleted from the secrets.json file:

Running dotnet user-secrets list displays the following message:

Additional resources

  • See this issue for information on accessing Secret Manager from IIS.

By Rick Anderson, Daniel Roth, and Scott Addie

View or download sample code (how to download)

This document explains techniques for storing and retrieving sensitive data during development of an ASP.NET Core app on a development machine. Never store passwords or other sensitive data in source code. Production secrets shouldn't be used for development or test. Secrets shouldn't be deployed with the app. Instead, secrets should be made available in the production environment through a controlled means like environment variables, Azure Key Vault, etc. You can store and protect Azure test and production secrets with the Azure Key Vault configuration provider.

Environment variables

Environment variables are used to avoid storage of app secrets in code or in local configuration files. Environment variables override configuration values for all previously specified configuration sources.

Consider an ASP.NET Core web app in which Individual User Accounts security is enabled. A default database connection string is included in the project's appsettings.json file with the key DefaultConnection. The default connection string is for LocalDB, which runs in user mode and doesn't require a password. During app deployment, the DefaultConnection key value can be overridden with an environment variable's value. The environment variable may store the complete connection string with sensitive credentials.

Warning

Environment variables are generally stored in plain, unencrypted text. If the machine or process is compromised, environment variables can be accessed by untrusted parties. Additional measures to prevent disclosure of user secrets may be required.

The : separator doesn't work with environment variable hierarchical keys on all platforms. __, the double underscore, is:

  • Supported by all platforms. For example, the : separator is not supported by Bash, but __ is.
  • Automatically replaced by a :

Secret Manager

The Secret Manager tool stores sensitive data during the development of an ASP.NET Core project. In this context, a piece of sensitive data is an app secret. App secrets are stored in a separate location from the project tree. The app secrets are associated with a specific project or shared across several projects. The app secrets aren't checked into source control.

Warning

The Secret Manager tool doesn't encrypt the stored secrets and shouldn't be treated as a trusted store. It's for development purposes only. The keys and values are stored in a JSON configuration file in the user profile directory.

How the Secret Manager tool works

The Secret Manager tool abstracts away the implementation details, such as where and how the values are stored. You can use the tool without knowing these implementation details. The values are stored in a JSON configuration file in a system-protected user profile folder on the local machine:

File system path:

%APPDATA%MicrosoftUserSecrets<user_secrets_id>secrets.json

File system path:

~/.microsoft/usersecrets/<user_secrets_id>/secrets.json

In the preceding file paths, replace <user_secrets_id> with the UserSecretsId value specified in the .csproj file.

Don't write code that depends on the location or format of data saved with the Secret Manager tool. These implementation details may change. For example, the secret values aren't encrypted, but could be in the future.

Enable secret storage

The Secret Manager tool operates on project-specific configuration settings stored in your user profile.

To use user secrets, define a UserSecretsId element within a PropertyGroup of the .csproj file. The inner text of UserSecretsId is arbitrary, but is unique to the project. Developers typically generate a GUID for the UserSecretsId.

Tip

In Visual Studio, right-click the project in Solution Explorer, and select Manage User Secrets from the context menu. This gesture adds a UserSecretsId element, populated with a GUID, to the .csproj file.

Set a secret

Define an app secret consisting of a key and its value. The secret is associated with the project's UserSecretsId value. For example, run the following command from the directory in which the .csproj file exists:

In the preceding example, the colon denotes that Movies is an object literal with a ServiceApiKey property.

The Secret Manager tool can be used from other directories too. Use the --project option to supply the file system path at which the .csproj file exists. For example:

JSON structure flattening in Visual Studio

Visual Studio's Manage User Secrets gesture opens a secrets.json file in the text editor. Replace the contents of secrets.json with the key-value pairs to be stored. For example:

The JSON structure is flattened after modifications via dotnet user-secrets remove or dotnet user-secrets set. For example, running dotnet user-secrets remove 'Movies:ConnectionString' collapses the Movies object literal. The modified file resembles the following:

Set multiple secrets

A batch of secrets can be set by piping JSON to the set command. In the following example, the input.json file's contents are piped to the set command.

Open a command shell, and execute the following command:

Open a command shell, and execute the following command:

Access a secret

The ASP.NET Core Configuration API provides access to Secret Manager secrets.

If your project targets .NET Framework, install the Microsoft.Extensions.Configuration.UserSecrets NuGet package.

In ASP.NET Core 2.0 or later, the user secrets configuration source is automatically added in development mode when the project calls CreateDefaultBuilder to initialize a new instance of the host with preconfigured defaults. CreateDefaultBuilder calls AddUserSecrets when the EnvironmentName is Development:

When CreateDefaultBuilder isn't called, add the user secrets configuration source explicitly by calling AddUserSecrets in the Startup constructor. Call AddUserSecrets only when the app runs in the Development environment, as shown in the following example:

User secrets can be retrieved via the Configuration API:

Map secrets to a POCO

Mapping an entire object literal to a POCO (a simple .NET class with properties) is useful for aggregating related properties.

Assume the app's secrets.json file contains the following two secrets:

To map the preceding secrets to a POCO, use the Configuration API's object graph binding feature. The following code binds to a custom MovieSettings POCO and accesses the ServiceApiKey property value:

The Movies:ConnectionString and Movies:ServiceApiKey secrets are mapped to the respective properties in MovieSettings:

String replacement with secrets

Storing passwords in plain text is insecure. For example, a database connection string stored in appsettings.json may include a password for the specified user:

A more secure approach is to store the password as a secret. For example:

Remove the Password key-value pair from the connection string in appsettings.json. For example:

The secret's value can be set on a SqlConnectionStringBuilder object's Password property to complete the connection string:

List the secrets

Assume the app's secrets.json file contains the following two secrets:

Run the following command from the directory in which the .csproj file exists:

The following output appears:

In the preceding example, a colon in the key names denotes the object hierarchy within secrets.json.

Remove a single secret

Assume the app's secrets.json file contains the following two secrets:

Run the following command from the directory in which the .csproj file exists:

The app's secrets.json file was modified to remove the key-value pair associated with the MoviesConnectionString key:

Running dotnet user-secrets list displays the following message:

Remove all secrets

Assume the app's secrets.json file contains the following two secrets:

Run the following command from the directory in which the .csproj file exists:

All user secrets for the app have been deleted from the secrets.json file:

Running dotnet user-secrets list displays the following message:

Photo Collage Maker is a digital scrapbooking and photo. Picture directory software.

Additional resources

  • See this issue for information on accessing Secret Manager from IIS.
-->

This article describes how to port your Windows Forms-based desktop app from .NET Framework to .NET Core 3.0 or later. The .NET Core 3.0 SDK includes support for Windows Forms applications. Windows Forms is still a Windows-only framework and only runs on Windows. This example uses the .NET Core SDK CLI to create and manage your project.

In this article, various names are used to identify types of files used for migration. When migrating your project, your files will be named differently, so mentally match them to the ones listed below:

FileDescription
MyApps.slnThe name of the solution file.
MyForms.csprojThe name of the .NET Framework Windows Forms project to port.
MyFormsCore.csprojThe name of the new .NET Core project you create.
MyAppCore.exeThe .NET Core Windows Forms app executable.

Prerequisites

  • Visual Studio 2019 16.5 Preview 1 or later for any designer work you want to do. We recommend to update to the latest Preview version of Visual Studio.

    Install the following Visual Studio workloads:

    • .NET desktop development
    • .NET Core cross-platform development
  • A working Windows Forms project in a solution that builds and runs without issue.

  • A project coded in C#.

Note

.NET Core 3.0 projects are only supported in Visual Studio 2019 or a later version. Starting with Visual Studio 2019 version 16.5 Preview 1, the .NET Core Windows Forms designer is also supported.

To enable the designer, go to Tools > Options > Environment > Preview Features and select the Use the preview Windows Forms designer for .NET Core apps option.

Consider

When porting a .NET Framework Windows Forms application, there are a few things you must consider.

  1. Check that your application is a good candidate for migration.

    Use the .NET Portability Analyzer to determine if your project will migrate to .NET Core 3.0. If your project has issues with .NET Core 3.0, the analyzer helps you identify those problems.

  2. You're using a different version of Windows Forms.

    When .NET Core 3.0 Preview 1 was released, Windows Forms went open source on GitHub. The code for .NET Core Windows Forms is a fork of the .NET Framework Windows Forms codebase. It's possible some differences exist and your app won't port.

  3. The Windows Compatibility Pack may help you migrate.

    Some APIs that are available in .NET Framework aren't available in .NET Core 3.0. The Windows Compatibility Pack adds many of these APIs and may help your Windows Forms app become compatible with .NET Core.

  4. Update the NuGet packages used by your project.

    It's always a good practice to use the latest versions of NuGet packages before any migration. If your application is referencing any NuGet packages, update them to the latest version. Ensure your application builds successfully. After upgrading, if there are any package errors, downgrade the package to the latest version that doesn't break your code.

Create a new SDK project

The new .NET Core 3.0 project you create must be in a different directory from your .NET Framework project. If they're both in the same directory, you may run into conflicts with the files that are generated in the obj directory. In this example, we'll create a directory named MyFormsAppCore in the SolutionFolder directory:

Next, you need to create the MyFormsCore.csproj project in the MyFormsAppCore directory. You can create this file manually by using the text editor of choice. Paste in the following XML:

If you don't want to create the project file manually, you can use Visual Studio or the .NET Core SDK to generate the project. However, you must delete all other files generated by the project template except for the project file. To use the SDK, run the following command from the SolutionFolder directory:

After you create the MyFormsCore.csproj, your directory structure should look like the following:

Add the MyFormsCore.csproj project to MyApps.sln with either Visual Studio or the .NET Core CLI from the SolutionFolder directory:

Fix assembly info generation

Windows Forms projects that were created with .NET Framework include an AssemblyInfo.cs file, which contains assembly attributes such as the version of the assembly to be generated. SDK-style projects automatically generate this information for you based on the SDK project file. Having both types of 'assembly info' creates a conflict. Resolve this problem by disabling automatic generation, which forces the project to use your existing AssemblyInfo.cs file.

There are three settings to add to the main <PropertyGroup> node.

  • GenerateAssemblyInfo
    When you set this property to false, it won't generate the assembly attributes. This avoids the conflict with the existing AssemblyInfo.cs file from the .NET Framework project.

  • AssemblyName
    The value of this property is the output binary created when you compile. The name doesn't need an extension added to it. For example, using MyCoreApp produces MyCoreApp.exe.

  • RootNamespace
    The default namespace used by your project. This should match the default namespace of the .NET Framework project.

Add these three elements to the <PropertyGroup> node in the MyFormsCore.csproj file:

Add source code

Right now, the MyFormsCore.csproj project doesn't compile any code. By default, .NET Core projects automatically include all source code in the current directory and any child directories. You must configure the project to include code from the .NET Framework project using a relative path. If your .NET Framework project used .resx files for icons and resources for your forms, you'll need to include those too.

Add the following <ItemGroup> node to your project. Each statement includes a file glob pattern that includes child directories.

Alternatively, you can create a <Compile> or <EmbeddedResource> entry for each file in your .NET Framework project.

Add NuGet packages

Add each NuGet package referenced by the .NET Framework project to the .NET Core project.

Most likely your .NET Framework Windows Forms app has a packages.config file that contains a list of all of the NuGet packages that are referenced by your project. You can look at this list to determine which NuGet packages to add to the .NET Core project. For example, if the .NET Framework project referenced the MetroFramework, MetroFramework.Design, and MetroFramework.Fonts NuGet packages, add each to the project with either Visual Studio or the .NET Core CLI from the SolutionFolder directory:

Dot Net Development On Mac

The previous commands would add the following NuGet references to the MyFormsCore.csproj project:

Port control libraries

If you have a Windows Forms Controls library project to port, the directions are the same as porting a .NET Framework Windows Forms app project, except for a few settings. And instead of compiling to an executable, you compile to a library. The difference between the executable project and the library project, besides paths for the file globs that include your source code, is minimal.

Using the previous step's example, lets expand what projects and files we're working with.

FileDescription
MyApps.slnThe name of the solution file.
MyControls.csprojThe name of the .NET Framework Windows Forms Controls project to port.
MyControlsCore.csprojThe name of the new .NET Core library project you create.
MyCoreControls.dllThe .NET Core Windows Forms Controls library.

Consider the differences between the MyControlsCore.csproj project and the previously created MyFormsCore.csproj project.

Here is an example of what the .NET Core Windows Forms Controls library project file would look like:

Dot Net For Mac

As you can see, the <OutputType> node was removed, which defaults the compiler to produce a library instead of an executable. The <AssemblyName> and <RootNamespace> were changed. Specifically the <RootNamespace> should match the namespace of the Windows Forms Controls library you are porting. And finally, the <Compile> and <EmbeddedResource> nodes were adjusted to point to the folder of the Windows Forms Controls library you are porting.

Next, in the main .NET Core MyFormsCore.csproj project, add a reference to the new .NET Core Windows Forms Control library. Add a reference with either Visual Studio or the .NET Core CLI from the SolutionFolder directory:

The previous command adds the following to the MyFormsCore.csproj project:

Compilation problems

If you have problems compiling your projects, you may be using some Windows-only APIs that are available in .NET Framework but not available in .NET Core. You can try adding the Windows Compatibility Pack NuGet package to your project. This package only runs on Windows and adds about 20,000 Windows APIs to .NET Core and .NET Standard projects.

Dot Net Apps On Mac Pc

The previous command adds the following to the MyFormsCore.csproj project:

Windows Forms Designer

As detailed in this article, Visual Studio 2019 only supports the Forms Designer in .NET Framework projects. By creating a side-by-side .NET Core project, you can test your project with .NET Core while you use the .NET Framework project to design forms. Your solution file includes both the .NET Framework and .NET Core projects. Add and design your forms and controls in the .NET Framework project, and based on the file glob patterns we added to the .NET Core projects, any new or changed files will automatically be included in the .NET Core projects.

Once Visual Studio 2019 supports the Windows Forms Designer, you can copy/paste the content of your .NET Core project file into the .NET Framework project file. Then delete the file glob patterns added with the <Source> and <EmbeddedResource> items. Fix the paths to any project reference used by your app. This effectively upgrades the .NET Framework project to a .NET Core project.

Next steps

  • Learn about breaking changes from .NET Framework to .NET Core.
  • Read more about the Windows Compatibility Pack.
  • Watch a video on porting your .NET Framework Windows Forms project to .NET Core.