1

I'm not very familiar with building dlls, nor with Visual Studio for that matter. But I have a couple of files in Unity3d which I always build a DLL using Visual Studio Command Prompt 2010. That seems to work fine, except is builds to .net target framework 4, and it needs to be 3.5 to work with Unity. However, I can't find the command line argument to specify this.

So, that's my question, how do I specify this in the command prompt? (if possible)

2
  • Are you using MSBuild to compile them? Commented Feb 7, 2015 at 17:29
  • I might? (I really don't know very well how it all works) I use Visual Studio Command Prompt 2010, and there I do: csc /target:library (...) Commented Feb 7, 2015 at 17:32

2 Answers 2

1

You should be able to go into the project properties (right click + properties on project name in solution) and specify the target framework there.

Sign up to request clarification or add additional context in comments.

5 Comments

I build the dll from the command prompt, it's only 2 files I build into a dll, they are not in a visual studio project.
If it's not possible using the command prompt, then I guess I'll have to make vs project for it and build it that way, it's just that I'm completely unfamiliar with vs, so it would be easier for me if I could just use a command line argument
Thanks, so I have to add "/p:TargetFrameworkVersion=v3.5;" right? or am I misunderstanding it? I'm not familiar with /p and cant seem to find anything about it.
/p just stands for property, so you are saying Property Target Framework Version... just google msbuild /p and it'll tell you all the parameters you can pass in
1

TargetFramework can be configured in the Project file only and can't be passed as a switch to CSC.exe, see settings for TargetFrameworkVersion and TargetFrameworkProfile in below example.

So the only way to dynamically set is to modify the project file with below setting and compile with csc.exe if you want to set Client Profile

Targetting .NET Framework 4.0 Client Profile

<PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{A5F58561-47CA-482A-83E0-1D43C312B0A7}</ProjectGuid>
    <OutputType>Exe</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>ConsoleApplication1</RootNamespace>
    <AssemblyName>ConsoleApplication1</AssemblyName>
    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <TargetFrameworkProfile>Client</TargetFrameworkProfile>
  </PropertyGroup>

Targetting .NET Framework 4.0

<PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{A5F58561-47CA-482A-83E0-1D43C312B0A7}</ProjectGuid>
    <OutputType>Exe</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>ConsoleApplication1</RootNamespace>
    <AssemblyName>ConsoleApplication1</AssemblyName>
    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <TargetFrameworkProfile></TargetFrameworkProfile>
  </PropertyGroup>

With MSBuild.exe:

msbuild.exe MyProj.proj /p:TargetFrameworkVersion=v2.0;Configuration=Release /tv:3.5

therefore overriding the value in the proj file as well as the ToolsVersion.

To find out which msbuild version default is used, start a Visual Studio Command prompt ( found in the Start menu > Microsoft Visual studio 2010 > Visual Studio Tools) and type msbuild. The first line of the output will hold your BuidEngineversion:

Microsoft (R) Build Engine Version 4.0.30319.1

From the msdn doc:

MSBuild uses a tool set of tasks, targets, and tools to build an application. Typically, a MSBuild tool set includes a microsoft.common.tasks file, a microsoft.common.targets file, and compilers such as csc.exe and vbc.exe. Most tool sets can be used to compile applications to more than one version of the .NET Framework and more than one system platform

You could aslo check the Environment vars for a version of the framework installed: set F from the Visual Studio Command prompt gives me this result:

Framework35Version=v3.5
FrameworkDir=c:\Windows\Microsoft.NET\Framework\
FrameworkDIR32=c:\Windows\Microsoft.NET\Framework\
FrameworkVersion=v4.0.30319
FrameworkVersion32=v4.0.30319

ToolSet Explanation ToolSetVersion

1 Comment

thanks for the answer. So it's not possible with just the command prompt? I'll try to make a project for it then (I already tried that earlier but it didn't work because I know nothing of visual studio projects, I use VS solely as an editor)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.