Fork me on GitHub

How to compile solutions and projects with assemblies (executables and dynamic libraries) ?

Gentoo Mono Handbook

dotnet.eclass reference

https://github.com/gentoo/dotnet/blob/master/eclass/dotnet.eclass#L81-L85

# @FUNCTION: exbuild
# @DESCRIPTION: run xbuild with Release configuration and configurated FRAMEWORK
exbuild() {
	xbuild "${1}" /p:Configuration=Release /tv:4.0 /p:TargetFrameworkVersion=v"${FRAMEWORK}" || die
}

About properties

MSBuild Properties, <Property ...> Element, <PropertyGroup ...> Element

Typical error messages

could not import "$(MSBuildBinPath)\Microsoft.CSharp.Targets"

# find /usr/lib/mono -name "Microsoft.CSharp.targets"
/usr/lib/mono/xbuild/12.0/bin/Microsoft.CSharp.targets
/usr/lib/mono/xbuild/14.0/bin/Microsoft.CSharp.targets
/usr/lib/mono/4.5/Microsoft.CSharp.targets

if 4.5 is set the error is
MSBUILD: error MSBUILD0000: Unknown tools version: '4.5' . Known versions: '2.0' '3.0' '3.5' '4.0' '12.0'
if 12.0 is set, then
could not import "$(MSBuildBinPath)\Microsoft.CSharp.Targets"

https://msdn.microsoft.com/en-us/library/bb383796.aspx
Toolset properties specify the paths of the tools. MSBuild uses the value of the ToolsVersion attribute in the project file to locate the corresponding registry key, and then uses the information in the registry key to set the Toolset properties.

Framework profiles

http://manpages.ubuntu.com/manpages/utopic/man1/xbuild.1.html
XBUILD_FRAMEWORK_FOLDERS_PATH
              With  ToolsVersion 4.0, projects can target arbitrary frameworks
              referenced by TargetFrameworkMoniker, which is of the format:

                Identifier,Version=<version>[,Profile=<profile>]

              Eg. ".NETFramework,Version=v4.0"

              The 3 parts of the moniker are given by the msbuild properties:

                $(TargetFrameworkIdentifier),  $(TargetFrameworkVersion)   and
              $(TargetFrameworkProfile)

              This moniker maps to a framework description file on disk:

                <framework_root>/Identifier/Version/[Profile]/RedistList/FrameworkList.xml

              This file is used to  determine  the  path  where  to  find  the
              framework assemblies for this particular framework.

              Framework  root  here  is  configurable  and  is resolved in the
              following order:

                1. Paths specified in the environment variable $XBUILD_FRAMEWORK_FOLDERS_PATH
                2. /Library/Frameworks/Mono.framework/External/xbuild-frameworks on Mac OSX.
                3. MSBuild property $(TargetFrameworkRoot)
                4. $prefix/lib/mono/xbuild-frameworks (default location)

              XBuild tries the paths given above, in order, till  it  finds  a
              FrameworkList.xml  for the moniker.  Running with /v:detailed or
              higher verbosity will show the various paths that it tries.

              The FrameworkList.xml itself just has a root element like:

                <FileList          Name=".NET          Framework          3.5"
              TargetFrameworkDirectory="..\..\..\..\3.5"
              IncludeFramework="v3.0">
                </FileList>

              Here  the  TargetFrameworkDirectory  attribute   specifies   the
              directory where the assemblies for this particular framework can
              be found. If this is not set, then  the  parent  of  the  folder
              containing the xml file is taken as the framework directory.

              IncludeFramework  attribute specifies the version of a framework
              (under the *same* $(TargetFrameworkIdentifier)) which should  be
              included in the final list of Target framework directories.

Variables of .csproj files

https://msdn.microsoft.com/en-us/library/ms164309.aspx
MSBuildBinPath

The absolute path of the folder where the MSBuild binaries that are currently being used are located (for example, C:\Windows\Microsoft.Net\Framework\versionNumber). This property is useful if you have to refer to files in the MSBuild directory.
Do not include the final backslash on this property.

MSBuildProjectDirectory
MSBuildProjectFile
MSBuildProjectFullPath
MSBuildProjectName
MSBuildToolsVersion