コード例 #1
0
        protected ProcessAssemblyBaseTest( string relativePath )
        {
            BeforeAssemblyPath = Path.GetFullPath( relativePath );
            #if !DEBUG
            BeforeAssemblyPath = BeforeAssemblyPath.Replace("Debug", "Release");
            #endif

            AfterAssemblyPath = BeforeAssemblyPath.Replace( ".dll", "2.dll" );
            File.Copy( BeforeAssemblyPath, AfterAssemblyPath, true );

            var moduleDefinition = ModuleDefinition.ReadModule( AfterAssemblyPath );

            var currentDirectory = AssemblyLocation.CurrentDirectory();
            PersistentInfo = PersistentInfo.LoadFromPath( currentDirectory );
            StandardInfo = new StandardInfo( PersistentInfo, moduleDefinition );

            var moduleWeaver = new ModuleWeaver
            {
                ModuleDefinition = moduleDefinition,
                AddinDirectoryPath = currentDirectory,
                SolutionDirectoryPath = currentDirectory,
                AssemblyFilePath = AfterAssemblyPath,
            };

            moduleWeaver.Execute();
            moduleDefinition.Write( AfterAssemblyPath );
            moduleWeaver.AfterWeaving();

            AfterAssembly = Assembly.LoadFile( AfterAssemblyPath );
        }
コード例 #2
0
ファイル: ModuleWeaver.cs プロジェクト: ismailfatih/CK-Stamp
    public void Execute()
    {
        SetSearchPath();
        using( var repo = GitFinder.TryLoadFromPath( SolutionDirectoryPath ) )
        {
            _info = new StandardInfo( new PersistentInfo( repo ), ModuleDefinition );

            var customAttributes = ModuleDefinition.Assembly.CustomAttributes;
            var attr = customAttributes.FirstOrDefault(x => x.AttributeType.Name == "AssemblyInformationalVersionAttribute");
            if( attr != null )
            {
                _informationalVersion = (string)attr.ConstructorArguments[0].Value;
                _informationalVersion = _info.ReplaceTokens( _informationalVersion );
                attr.ConstructorArguments[0] = new CustomAttributeArgument( ModuleDefinition.TypeSystem.String, _informationalVersion );
            }
            else
            {
                var versionAttribute = GetVersionAttribute();
                var constructor = ModuleDefinition.Import( versionAttribute.Methods.First( x => x.IsConstructor ) );
                attr = new CustomAttribute( constructor );
                _informationalVersion = _info.ToString();
                attr.ConstructorArguments.Add( new CustomAttributeArgument( ModuleDefinition.TypeSystem.String, _informationalVersion ) );
                customAttributes.Add( attr );
            }
        }
    }