.vcxproj file information for c++/cli projects and .csproj file information for c# projects
C++/CLI project
For a C++/CLI project that builds against .NetCore, in its .vcxproj file the configuration contents should look like:
<PropertyGroup Label="Globals">
...
<CLRSupport>NetCore</CLRSupport>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<Import Project="$(MaxSDK)\ProjectSettings\PropertySheets\3dsmax.general.project.settings.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="PropertySheets">
<Import Project="$(MaxSDK)\ProjectSettings\PropertySheets\3dsmax.cpp.props" />
</ImportGroup>
Before the Import Project, depending in the Windows specific requirements of your project, you may need to specify one of the following. These are used by the compiler to determine which sets of assemblies to automatically reference:
<ItemGroup>
<FrameworkReference Include="Microsoft.WindowsDesktop.App" />
</ItemGroup>
or
<ItemGroup>
<FrameworkReference Include="Microsoft.WindowsDesktop.App.WindowsForms" />
</ItemGroup>
or
<ItemGroup>
<FrameworkReference Include="Microsoft.WindowsDesktop.App.WPF" />
</ItemGroup>
If a FrameworkReference is specified, the following is needed:
<PropertyGroup Label="Globals">
...
<EnableManagedPackageReferenceSupport>true</EnableManagedPackageReferenceSupport>
</PropertyGroup>
When specifying a FrameworkReference, in some cases you may get build warnings looking like:
warning: 729>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2382,5): warning MSB3277: Found conflicts between different versions of "System.Drawing" that could not be resolved.
warning: 729>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2382,5): warning MSB3277: There was a conflict between "System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.Drawing, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
warning: 729>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2382,5): warning MSB3277: "System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was chosen because it was primary and "System.Drawing, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was not.
warning: 729>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2382,5): warning MSB3277: References which depend on "System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\8.0.12\ref\net8.0\System.Drawing.dll].
warning: 729>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2382,5): warning MSB3277: C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\8.0.12\ref\net8.0\System.Drawing.dll
warning: 729>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2382,5): warning MSB3277: Project file item includes which caused reference "C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\8.0.12\ref\net8.0\System.Drawing.dll".
warning: 729>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2382,5): warning MSB3277: C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\8.0.12\ref/net8.0/System.Drawing.dll
warning: 729>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2382,5): warning MSB3277: References which depend on "System.Drawing, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [].
warning: 729>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2382,5): warning MSB3277: G:\2026\3dswin\bin\x64\Release\sceneExplorer.dll
warning: 729>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2382,5): warning MSB3277: Project file item includes which caused reference "G:\2026\3dswin\bin\x64\Release\sceneExplorer.dll".
warning: 729>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2382,5): warning MSB3277: sceneExplorer
As long as dealing with Microsoft .Net Core packages, you can ignore these as warnings by specifying:
<PropertyGroup>
<MSBuildWarningsAsMessages>$(MSBuildWarningsAsMessages);MSB3277</MSBuildWarningsAsMessages>
</PropertyGroup>
If your project requires BinaryFormatter, the following needs to be specified:
<PropertyGroup Label="Globals">
...
<EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization>
</PropertyGroup>
Note the BinaryFormatter is deprecated and does not exist in .Net Core 9. A nuget package is available to support BinaryFormatter in .Net Core 9, but it is recommended to move away from BinaryFormatter. See https://learn.microsoft.com/en-us/dotnet/standard/serialization/binaryformatter-migration-guide/compatibility-package.
If your project requires nuget packages, they would be specified as such:
<ItemGroup>
<ProjectCapability Include="PackageReferences" />
<PackageReference Include="System.Drawing.Common" Version="8.0.11" />
</ItemGroup>
If a nuget packages are specified, the following is needed:
<PropertyGroup Label="Globals">
...
<EnableManagedPackageReferenceSupport>true</EnableManagedPackageReferenceSupport>
</PropertyGroup>
For general information on how to port a C++/CLI project to .Net Core, see https://learn.microsoft.com/en-us/dotnet/core/porting/cpp-cli.
.vcxprojs in maxsdk that build with NetCore support:
maxsdk\howto\SceneExplorerExtension\SceneExplorerExtension.vcxproj maxsdk\samples\systems\sunlight\sunlight.vcxproj
C# projects
The critical part of the .net core version is that the file begins with:
<Project Sdk="">
<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<EnableDefaultEmbeddedResourceItems>false</EnableDefaultEmbeddedResourceItems>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
</PropertyGroup>
<PropertyGroup>
<Platforms>x64</Platforms>
<Configurations>Debug;Release</Configurations>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<EnableDefaultEmbeddedResourceItems>false</EnableDefaultEmbeddedResourceItems>
</PropertyGroup>
instead of:
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
After the configuration data is specifed add the following:
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
If you specify BaseIntermediateOutputPath, which defines where to send files generated by msbuild and nuget, it needs to be defined before importing Sdk.props and Sdk.targets
Remove:
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
After that it is mainly about the removal of unnecessary configuration settings, removal of most '
If using BinarySerializer (see comments above in vcxproj file discussion), you need to specify USE_BINARY_SERIALIZER:
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DefineConstants>TRACE;DEBUG;USE_BINARY_SERIALIZER</DefineConstants>
<Optimize>false</Optimize>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<DefineConstants>TRACE;USE_BINARY_SERIALIZER</DefineConstants>
<Optimize>true</Optimize>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
If get warning similar to:
warning CA1416: This call site is reachable on all platforms. 'ICharStream.Printf(string, params object[])' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)
Add to AssemblyInfo.cs:
[assembly: System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")]
If get warning similar to:
warning MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "Autodesk.Max", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.
Change:
<PlatformTarget>AnyCPU</PlatformTarget>
to
<PlatformTarget>x64</PlatformTarget>
.csprojs in maxsdk that build with NetCore support:
maxsdk\howto\DotNetCore\DotNetCore_TestProj.csproj