LC.EXE Command Line Problem

HTIHTI Posts: 6
edited November 10, 2005 5:20AM in SQL Toolkit Previous Versions
Compiling the LICX file in from VS.NET works fine now, however when attempting to build it in my NANT script (or from the command line) I get the following errors:
C:\>lc /target:my.exe /complist:licenses.licx /v
Microsoft (R) .NET License Compiler
[Microsoft .Net Framework, Version 1.1.4322.573]
Copyright (C) Microsoft Corporation 1998-2002. All rights reserved.

Processing complist 'licenses.licx'...
licenses.licx(1) : info LC0001 : Processing component entry 'RedGate.SQLCompare.Engine.Database'
licenses.licx(1) : error LC0003 : Unabled to resolve type 'RedGate.SQLCompare.Engine.Database'
licenses.licx(2) : info LC0001 : Processing component entry 'RedGate.SQLDataCompare.Engine.ComparisonSession'
licenses.licx(2) : error LC0003 : Unabled to resolve type 'RedGate.SQLDataCompare.Engine.ComparisonSession'
Creating Licenses file my.exe.licenses...

I have tried copied all of the appropriate RedGate dlls to the current directory, but that does not seem to work either.

What should the correct command line options be to LC.EXE?

Comments

  • Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    Hi,

    The .NET component licensing can be tricky indeed. If it works in Visual Studio, but not in Lc.exe, maybe it will help if you give lc.exe more information in licenses.licx. Can you try adding the following to licenses.licx?

    RedGate.SQLDataCompare.Engine.ComparisonSession, RedGate.SQLDataCompare.Engine, Version=3.3.9.14, Culture=neutral, PublicKeyToken=00240000048000009400000006020000002400005253413100040000010001008FC10F454406BF85568F958675567383EB344EF516BEC3937AAD9239B15EDF1EB663E2501CE211AB47FB6C26554697B487E8CDA6B2D662B42146417D62AA9C74C4719BC5910DB2659584ADC4F07F0687744B038085B76CC6336A7108738CCFD0AABE44760EC94C8DFD29009FC2DEF78455CE1920A2A5696D108734386CE04AD9

    RedGate.SQLCompare.Engine.Database, RedGate.SQLCompare.Engine, Version=3.2.0.5, Culture=neutral, PublicKeyToken=00240000048000009400000006020000002400005253413100040000010001008FC10F454406BF85568F958675567383EB344EF516BEC3937AAD9239B15EDF1EB663E2501CE211AB47FB6C26554697B487E8CDA6B2D662B42146417D62AA9C74C4719BC5910DB2659584ADC4F07F0687744B038085B76CC6336A7108738CCFD0AABE44760EC94C8DFD29009FC2DEF78455CE1920A2A5696D108734386CE04AD9
  • No luck:
    C:\MSDEV\v2.1.6\Mediscribe.Install\Mediscribe.Install.SystemConfiguration>lc /ta
    rget:my.exe /complist:licenses.licx /v
    Microsoft (R) .NET License Compiler
    [Microsoft .Net Framework, Version 1.1.4322.573]
    Copyright (C) Microsoft Corporation 1998-2002. All rights reserved.


    Processing complist 'licenses.licx'...
    licenses.licx(1) : info LC0001 : Processing component entry 'RedGate.SQLDataComp
    are.Engine.ComparisonSession, RedGate.SQLDataCompare.Engine, Version=3.3.9.14, C
    ulture=neutral, PublicKeyToken=0024000004800000940000000602000000240000525341310
    0040000010001008FC10F454406BF85568F958675567383EB344EF516BEC3937AAD9239B15EDF1EB
    663E2501CE211AB47FB6C26554697B487E8CDA6B2D662B42146417D62AA9C74C4719BC5910DB2659
    584ADC4F07F0687744B038085B76CC6336A7108738CCFD0AABE44760EC94C8DFD29009FC2DEF7845
    5CE1920A2A5696D108734386CE04AD9 '
    licenses.licx(1) : error LC0003 : Unabled to resolve type 'RedGate.SQLDataCompar
    e.Engine.ComparisonSession, RedGate.SQLDataCompare.Engine, Version=3.3.9.14, Cul
    ture=neutral, PublicKeyToken=002400000480000094000000060200000024000052534131000
    40000010001008FC10F454406BF85568F958675567383EB344EF516BEC3937AAD9239B15EDF1EB66
    3E2501CE211AB47FB6C26554697B487E8CDA6B2D662B42146417D62AA9C74C4719BC5910DB265958
    4ADC4F07F0687744B038085B76CC6336A7108738CCFD0AABE44760EC94C8DFD29009FC2DEF78455C
    E1920A2A5696D108734386CE04AD9 '
    licenses.licx(2) : info LC0001 : Processing component entry 'RedGate.SQLCompare.
    Engine.Database, RedGate.SQLCompare.Engine, Version=3.2.0.5, Culture=neutral, Pu
    blicKeyToken=00240000048000009400000006020000002400005253413100040000010001008FC
    10F454406BF85568F958675567383EB344EF516BEC3937AAD9239B15EDF1EB663E2501CE211AB47F
    B6C26554697B487E8CDA6B2D662B42146417D62AA9C74C4719BC5910DB2659584ADC4F07F0687744
    B038085B76CC6336A7108738CCFD0AABE44760EC94C8DFD29009FC2DEF78455CE1920A2A5696D108
    734386CE04AD9'
    licenses.licx(2) : error LC0003 : Unabled to resolve type 'RedGate.SQLCompare.En
    gine.Database, RedGate.SQLCompare.Engine, Version=3.2.0.5, Culture=neutral, Publ
    icKeyToken=00240000048000009400000006020000002400005253413100040000010001008FC10
    F454406BF85568F958675567383EB344EF516BEC3937AAD9239B15EDF1EB663E2501CE211AB47FB6
    C26554697B487E8CDA6B2D662B42146417D62AA9C74C4719BC5910DB2659584ADC4F07F0687744B0
    38085B76CC6336A7108738CCFD0AABE44760EC94C8DFD29009FC2DEF78455CE1920A2A5696D10873
    4386CE04AD9'
    Creating Licenses file my.exe.licenses...
  • Bart ReadBart Read Posts: 997 Silver 1
    Hi there,


    Around 9 months ago now we updated our build system and began using NAnt to build our projects and I experienced exactly the problem you're having.

    Basically whatever we did we could not get lc.exe to work. I even looked at lc.exe using Lutz Roeder's .NET Reflector, and from the code couldn't figure out how it possibly could work. In the end what I did was to quickly hack together an NAnt task to wrap devenv.exe and build our VS.NET projects. I had previously tried using the NAnt 'solution' task, as well as carrying out all the build steps manually, but to no avail.

    This might not be what you're looking to do, however it will build VS.NET projects (you'll need to change the exe path for 2003 though, as it looks like the default is set to 2002 - really we should grab this value from the registry), and will compile the licenses in as you need it to. The problem of course is that way VS.NET builds projects is a complete black box so you've no control whatsoever, except that with 2003 you can of course specify pre- and post-build events.

    Anyway, I hope this helps you out. I've pasted the code into my next message. Also, should you need a copy of the GNU LGPL you can find it in plaintext format at http://www.gnu.org/licenses/lgpl.txt.


    Kind regards,
    Bart Read
    Principal Consultant
    bartread.com Ltd
  • Bart ReadBart Read Posts: 997 Silver 1
    #region GNU General Public License
    //
    // NAntContrib
    // Copyright (C) 2001-2003 Gerry Shaw
    //
    //
    // This library is free software; you can redistribute it and/or
    // modify it under the terms of the GNU Lesser General Public
    // License as published by the Free Software Foundation; either
    // version 2.1 of the License, or (at your option) any later version.
    //
    // This library is distributed in the hope that it will be useful,
    // but WITHOUT ANY WARRANTY; without even the implied warranty of
    // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    // Lesser General Public License for more details.
    //
    // You should have received a copy of the GNU Lesser General Public
    // License along with this library; if not, write to the Free Software
    // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    //
    
    // Jason Reimer, Diversant Inc. (jason.reimer@diversant.net)
    // William E. Caputo, ThoughtWorks Inc. (billc@thoughtworks.com)
    #endregion
    
    using System;
    using System.Diagnostics;
    using System.IO;
    using System.Text;
    
    using NAnt.Core;
    using NAnt.Core.Attributes;
    
    namespace NAnt.RedGateTasks {
    
        /// <summary>
        /// Builds Visual Studio solutions and project files using
        /// devenv.exe.
        /// Author: Bart Read
        /// </summary>
        [TaskName("vsnetbuild")]
        public sealed class VSNETBuildTask : Task {
    
            string  _exeName        = @"C:\Program Files\Microsoft Visual Studio .NET\Common7\IDE\devenv.exe";
            string  _solution;
            string  _solutionConfig;
            string  _project;
            string  _projectConfig;
            bool    _rebuild        = true;
            bool    _clean;
            bool    _deploy;
    
            string  _tempFile;
    
            [TaskAttribute("exename")]
            public string ExeName {
                get { return _exeName; }
                set { _exeName = value; }
            }
    
            /// <summary>
            /// Name of a solution (.sln) file.  May also
            /// be the name of a project file, but note that
            /// if no .sln file is specified then the specified
            /// project file will be used as the solution.
            /// </summary>
            [TaskAttribute("solution")]
            public string Solution {
                get { return _solution; }
                set { _solution = value; }
            }
    
            /// <summary>
            /// Specifies solution configuration to build.
            /// </summary>
            [TaskAttribute("solutionconfig")]
            public string SolutionConfig {
                get { return _solutionConfig; }
                set { _solutionConfig = value; }
            }
    
            /// <summary>
            /// Specifies the project to build instead of solution.
            /// </summary>
            [TaskAttribute("project")]
            public string ProjectFile {
                get { return _project; }
                set { _project = value; }
            }
    
            /// <summary>
            /// Specifies the project configuration to build.  Must
            /// also specify project name.
            /// </summary>
            [TaskAttribute("projectconfig")]
            public string ProjectConfig {
                get { return _projectConfig; }
                set { _projectConfig = value; }
            }
    
            /// <summary>
            /// Do rebuild (i.e. clean before build) rather than build.
            /// Default is true.
            /// </summary>
            [TaskAttribute("rebuild")]
            public bool Rebuild {
                get { return _rebuild; }
                set { _rebuild = value; }
            }
    
            /// <summary>
            /// Clean up build outputs.
            /// </summary>
            [TaskAttribute("clean")]
            public bool Clean {
                get { return _clean; }
                set { _clean = value; }
            }
    
            /// <summary>
            /// Build the specified solution configuration and then deploy it.
            /// </summary>
            [TaskAttribute("deploy")]
            public bool Deploy {
                get { return _deploy; }
                set { _deploy = value; }
            }
    
            bool _ignoreErrors   = false;
    
            /// <summary>
            /// 
            /// </summary>
            /// <returns></returns>
            [TaskAttribute("ignoreerrors")]
            public bool IgnoreErrors {
                get { return _ignoreErrors; }
                set { _ignoreErrors = value; }
            }
    
            private string CreateArguments() {
                StringBuilder buff  = new StringBuilder();
    
                buff.Append( "\"" + ( null == Solution ? ProjectFile : Solution ) + "\"" );
                buff.Append( Rebuild ? " /rebuild " : " /build " );
                buff.Append( null == SolutionConfig ? ProjectConfig : SolutionConfig );
    
    //            if ( null != ProjectFile ) {
    //                buff.Append( " /project " );
    //                buff.Append( ProjectFile );
    //                if ( null != ProjectConfig ) {
    //                    buff.Append( " /projectconfig " );
    //                    buff.Append( ProjectConfig );
    //                }
    //            }
    
                buff.Append( " /out " );
                buff.Append( "\"" + _tempFile + "\"" );
    
                if ( Clean ) {
                    buff.Append( " /clean" );
                }
    
                if ( Deploy ) {
                    buff.Append( " /deploy" );
                }
    
                return buff.ToString();
            }
    
            protected override void ExecuteTask() {
                _tempFile   = Path.GetTempFileName();
    
                try {
                    Process p = new Process();
                    p.StartInfo.FileName	= ExeName;
                    p.StartInfo.Arguments	= CreateArguments();
                    Log(Level.Info, "Running : \"" + ExeName + "\" " + p.StartInfo.Arguments);
                    p.StartInfo.RedirectStandardOutput = true;
                    p.StartInfo.UseShellExecute = false;
                    p.Start();
                    string output = p.StandardOutput.ReadToEnd();
                    Log(Level.Info, "Output from '" + ExeName + "'");
                    Log(Level.Info, output);
                    p.WaitForExit();
    
                    FileStream      fin         = new FileStream(_tempFile, FileMode.Open, FileAccess.Read);
                    StreamReader    rin         = new StreamReader(fin);
                    int             exitCode    = p.ExitCode;
    
                    string          buildLog    = rin.ReadToEnd();
    
                    Log(0 == exitCode || this.IgnoreErrors ? Level.Info : Level.Error, "Build output:" );
                    Log(0 == exitCode || this.IgnoreErrors ? Level.Info : Level.Error, buildLog);
    
                    rin.Close();
                    fin.Close();
    
                    if (0 != exitCode) {
                        if (!this.IgnoreErrors) {
                            throw new BuildException(
                                "Error executing " + Name + " task. '" + ExeName + "' returned a non-zero exit code: " + p.ExitCode + "\n\n" + buildLog);
                        } else {
                            Log(Level.Warning, "Ignoring build problems.");
                        }
                    }
                } catch ( Exception e ) {
                    if (!this.IgnoreErrors) {
                        throw new BuildException("Error executing " + Name + " task: " + e.Message, e);
                    } else {
                        Log(Level.Warning, "Ignoring build problems.");
                    }
                }
                finally {
                    try {
                        File.Delete(_tempFile);
                    } catch {}
                }
            }
    
        }
    }
    
    Bart Read
    Principal Consultant
    bartread.com Ltd
  • Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    This could also be because of a crypto problem... I'd discovered yesterday, quite by accident, that you cannot get the licensing to work if the build is using an RSA key from the machinekey store as opposed to loading the key from your profile.

    I believe that if your build process is running as the LocalSystem account, you may get this error for that reason. If that's the case, then the solution would be to run your automated build process as a named user, one that has a valid profile that can be loaded.

    Hopefully this helps!
Sign In or Register to comment.