multi targeting in command line compiler (csc.exe)

前端 未结 2 1851
旧时难觅i
旧时难觅i 2021-01-24 12:19

My question is simple: How can I do multi-targeting in command line compiler (csc.exe), especially to .Net 4 Client Profile?


edit: Ok, Is my que

2条回答
  •  轮回少年
    2021-01-24 12:59

    If you need to compile at runtime, then you should consider the providers in System.CodeDOM, which allow compilation without invoking a separate process.

    To answer your original question, if you turn the MSBuild verbosity to Detailed in Visual Studio (Options - Projects and Solutions - Build and Run) and build a project targeted at client profile, you will see this in the build output:

    Csc.exe (stuff...) Program.cs Properties\AssemblyInfo.cs "C:\...\Temp\.NETFramework,Version=v4.0,Profile=Client.AssemblyAttributes.cs"

    The path in quotes is actually a generated temp file, containing:

    [assembly: TargetFrameworkAttribute(".NETFramework,Version=v4.0,Profile=Client", FrameworkDisplayName = ".NET Framework 4 Client Profile")]

    So, you should be able to use that attribute in your own code if you are invoking csc directly.

提交回复
热议问题