Forums

how to specify similar assemblies of different versions

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

how to specify similar assemblies of different versions

Postby RIGHT_THEN » Thu May 26, 2011 12:09 am

Hey Charles

below is excerpt from Msbuild file

<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>

<Reference Include="System.Speech, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
</Reference>



how would one pass these references to cobra compiler which belong to
different versions of the Framework.

Senario:-
say one is using .net 4.0 Cobra compiler, but has certain asemblies
of 3.5 version which one cannot spare. in the Gac.
now C# will automatically gun for .net 4.0 assemblies from GAC. and so would
cobra because of mscorlib 4.0. when it would try to use reflection etc..

above stated way is to specify to c# compiler
but what to do with Cobra. is there a way.

because as far as i know -lib:- can only be passed paths
and ref:- cannot be passed anything other than assembly name

this problem is with Gac assemblies only. Private assemblies would work
fine because of explicit path in the -lib:-

Thanking_You
RIGHT_THEN
RIGHT_THEN
 
Posts: 99

Re: how to specify similar assemblies of different versions

Postby Charles » Thu May 26, 2011 1:24 am

I'm about to retire for the evening, so I don't have the time to research this right now, but do you know how msbuild gets those references to C#? Is there a "full name" format that the C# compiler can take? For example, gacutil will report names like "System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which matches the run-time names that assemblies report.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: how to specify similar assemblies of different versions

Postby RIGHT_THEN » Thu May 26, 2011 1:49 am

Charles wrote:I'm about to retire for the evening, so I don't have the time to research this right now


sure there is no hurry

Charles wrote:but do you know how msbuild gets those references to C#? Is there a "full name" format that the C# compiler can take?


MsBuild Is using its toolchain utilities which are located in assembly
for .net 4.0 and similarly for other versions

C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.Build.Utilities.v4.0\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.Build.Utilities.v4.0.dll



Code: Select all
// Microsoft.Build.Utilities.ToolLocationHelper
/// <summary>Gets a fully qualified path to the .NET Framework root directory.</summary>
/// <returns>A string containing the fully qualified path to the .NET Framework root directory, or a null reference (Nothing in Visual Basic) if the targeted version of the .NET Framework is not installed.</returns>
/// <param name="version">The version of the .NET Framework to target.</param>
[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
public static string GetPathToDotNetFramework(TargetDotNetFrameworkVersion version)
{
}


// Microsoft.Build.Utilities.ToolLocationHelper
/// <summary>Returns the paths to the reference assemblies location for the given target framework. This method will assume the requested ReferenceAssemblyRoot path will be the ProgramFiles directory specified by Environment.SpecialFolder.ProgramFiles In additon when the .NETFramework or .NET Framework targetFrameworkIdentifiers are seen and targetFrameworkVersion is 2.0, 3.0, 3.5 or 4.0 we will return the correctly chained reference assembly paths for the legacy .NET Framework versions. This chaining will use the existing GetPathToDotNetFrameworkReferenceAssemblies to build up the list of reference assembly paths.</summary>
/// <returns>Collection of reference assembly locations.</returns>
/// <param name="targetFrameworkIdentifier">Identifier being targeted</param>
/// <param name="targetFrameworkVersion">Version being targeted</param>
/// <param name="targetFrameworkProfile">Profile being targeted</param>
/// <exception cref="T:System.ArgumentNullException">When the frameworkName is null</exception>
public static IList<string> GetPathToReferenceAssemblies(string targetFrameworkIdentifier, string targetFrameworkVersion, string targetFrameworkProfile)
{
}

and similar functions there are a lot of GetPath functions in this Class

MsBuild is calling such functionalities like this is Microsoft.Common.Targets
Code: Select all
<PropertyGroup>
        <TargetFrameworkMoniker Condition="'$(TargetFrameworkMoniker)' == '' and '$(TargetFrameworkProfile)' != ''">$(TargetFrameworkIdentifier),Version=$(TargetFrameworkVersion),Profile=$(TargetFrameworkProfile)</TargetFrameworkMoniker>
        <TargetFrameworkMoniker Condition="'$(TargetFrameworkMoniker)' == ''">$(TargetFrameworkIdentifier),Version=$(TargetFrameworkVersion)</TargetFrameworkMoniker>

      <!-- The FrameworkPathOverride is required for the inproc visual basic compiler to initialize when targeting target frameworks less than 4.0. If .net 2.0 is not installed then the property value above will not provide the location
             of mscorlib. This is also true if the build author overrides this property to some other directory which does not contain mscorlib.dll. In the case we cannot find mscorlib.dll at the correct location
             we need to find a directory which does contain mscorlib to allow the inproc compiler to initialize and give us the chance to show certain dialogs in the IDE (which only happen after initialization).-->
      <FrameworkPathOverride Condition="'$(FrameworkPathOverride)' == ''">$([Microsoft.Build.Utilities.ToolLocationHelper]::GetPathToStandardLibraries($(TargetFrameworkIdentifier), $(TargetFrameworkVersion), $(TargetFrameworkProfile)))</FrameworkPathOverride>
      <FrameworkPathOverride Condition="!Exists('$(FrameworkPathOverride)\mscorlib.dll')">$(MSBuildToolsPath)</FrameworkPathOverride>

    </PropertyGroup>


<FrameworkPathOverride Condition="'$(FrameworkPathOverride)' == ''">$([Microsoft.Build.Utilities.ToolLocationHelper]::GetPathToStandardLibraries($(TargetFrameworkIdentifier), $(TargetFrameworkVersion), $(TargetFrameworkProfile)))</FrameworkPathOverride>
<FrameworkPathOverride Condition="!Exists('$(FrameworkPathOverride)\mscorlib.dll')">$(MSBuildToolsPath)</FrameworkPathOverride>

this bold is from above code snippet because i dont know how to Bold when wrapped in code tags


now while building Msbuild is using above mentioned features and presenting info like
Primary reference "System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089".
Resolved file path is "C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Core.dll".
Reference found at search path location "{TargetFrameworkDirectory}".
For SearchPath "{TargetFrameworkDirectory}".
Considered "C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Core.exe", but it didn't exist.
This reference is not "CopyLocal" because it's a prerequisite file.
Done executing task "ResolveAssemblyReference".
.


after resolving paths Msbuild is passing info to C# compiler like this
/reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Core.dll"

which is a absolute path now compiler will have no confusion
whereas Cobras -ref:- does not allow including paths
either expand -ref:- to include paths or introduce -refStrict:- or refWithPath:- for this to work.

or am i missing something very obvious in Cobra that i have overlooked

.net 4.0 does allow using multiple version assemblies and sooner or later
users of cobra might use this feature. or hit a wall working on external projects.

resolving path and all i can take care of in my .cobraproj file give me a switch to
specify path of assembly explicitly



Thanking_You
RIGHT_THEN
RIGHT_THEN
 
Posts: 99

Re: how to specify similar assemblies of different versions

Postby Charles » Thu May 26, 2011 8:37 am

Looks like we need to enhance Cobra to support paths being passed to -ref.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: how to specify similar assemblies of different versions

Postby Charles » Thu May 26, 2011 10:47 pm

Actually, I am able to use paths with -ref:
Code: Select all
# Windows 7 64-bit
> cobra -v:1 -ref:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll" hello.cobra
...
Loading reference: C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll
Reading assembly:  System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
              at:  C:\Windows\assembly\GAC_MSIL\System.Core\3.5.0.0__b77a5c561934e089\System.Core.dll
...
Running: hello
---------------------------------------------------------------------------------------------------------------------
Hello, world.

Let me know how it goes for you.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: how to specify similar assemblies of different versions

Postby RIGHT_THEN » Fri May 27, 2011 12:59 am

i tested it on small example of using winforms and speech
and it worked.
but i am sure i read and tested before that -ref: wont
accept paths

well it does now!! :shock:

Thanking_You
RIGHT_THEN
RIGHT_THEN
 
Posts: 99

Re: how to specify similar assemblies of different versions

Postby hopscc » Fri May 27, 2011 8:07 am

Do you remember where you read/saw that ? ( -ref not accept a path)
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: how to specify similar assemblies of different versions

Postby RIGHT_THEN » Fri May 27, 2011 1:50 pm

hopscc wrote:Do you remember where you read/saw that ? ( -ref not accept a path)

hello Mr.hopscc

On
http://cobra-language.com/trac/cobra/wiki/CommandLine
•Providing references and library search path -reference/-ref -library-directory/-lib -embed-run-time/-ert

and on cobra.exe -h

-reference:Some.dll
-ref
Add a DLL reference.

but i cant figure out/remember precisely where it is written that -ref: should not include paths
or could have misunderstood that references are in -ref: and their search path is in -lib:

Dumb of me then i think

Thanking_You
RIGHT_THEN
RIGHT_THEN
 
Posts: 99

Re: how to specify similar assemblies of different versions

Postby hopscc » Sat May 28, 2011 7:33 am

Fair enough.

That commandline page is obviously incomplete and needs augmenting anyway
At least the major options should have something more extensive said about them.
One day.....
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand


Return to Discussion

Who is online

Users browsing this forum: No registered users and 42 guests