Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Dynamic assembly information

Dynamic assembly information

Scheduled Pinned Locked Moved C#
csharpquestionannouncement
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Helfdane
    wrote on last edited by
    #1

    Hi, Our solution in .net 3.5 has a number of dll's as output. In those dll's we populate some fields like version, company, product etc. But also a copyright notice. For instance, if I have this notice: "Copyright (c) 2011 Initech Inc.". Is it possible to make the year value be determined at compile time? So, if I compile it in 2011, then it says "Copyright (c) 2011 Initech Inc.". If I compile it in 2012, it would say "Copyright (c) 2012 Initech Inc.". I've toyed with some things, but AssemblyCopyright requires a constant as value. Is it possible at all?

    The consumer isn't a moron; she is your wife.

    R P 2 Replies Last reply
    0
    • H Helfdane

      Hi, Our solution in .net 3.5 has a number of dll's as output. In those dll's we populate some fields like version, company, product etc. But also a copyright notice. For instance, if I have this notice: "Copyright (c) 2011 Initech Inc.". Is it possible to make the year value be determined at compile time? So, if I compile it in 2011, then it says "Copyright (c) 2011 Initech Inc.". If I compile it in 2012, it would say "Copyright (c) 2012 Initech Inc.". I've toyed with some things, but AssemblyCopyright requires a constant as value. Is it possible at all?

      The consumer isn't a moron; she is your wife.

      R Offline
      R Offline
      Ravi Sant
      wrote on last edited by
      #2

      This always works for me :) Hope it helps.

      StreamReader reader = new StreamReader(@"C:\FilePath\AssemblyInfo.cs");
      string contents = reader.ReadToEnd();
      reader.Close();

              string NewCopyrightText = "Yippie. All rights reserved " + DateTime.Now.Year;
              // replace assembly version
              string replacement = "\[assembly: AssemblyCompany(\\"" + NewCopyrightText + "\\")\]";
              contents = Regex.Replace(contents, @"\\\[assembly: AssemblyCompany\\("".\*""\\)\\\]", replacement);
              
              StreamWriter writer = new StreamWriter(@"C:\\FilePath\\AssemblyInfo.cs", false);
              writer.Write(contents);
              writer.Close();
      
      H 1 Reply Last reply
      0
      • H Helfdane

        Hi, Our solution in .net 3.5 has a number of dll's as output. In those dll's we populate some fields like version, company, product etc. But also a copyright notice. For instance, if I have this notice: "Copyright (c) 2011 Initech Inc.". Is it possible to make the year value be determined at compile time? So, if I compile it in 2011, then it says "Copyright (c) 2011 Initech Inc.". If I compile it in 2012, it would say "Copyright (c) 2012 Initech Inc.". I've toyed with some things, but AssemblyCopyright requires a constant as value. Is it possible at all?

        The consumer isn't a moron; she is your wife.

        P Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #3

        Helfdane wrote:

        Copyright (c)

        That's redundant. "The symbol © (the letter C in a circle), or the word “Copyright,” or the abbreviation “Copr.”;" -- http://www.copyright.gov/circs/circ1.pdf[^]

        T 1 Reply Last reply
        0
        • P PIEBALDconsult

          Helfdane wrote:

          Copyright (c)

          That's redundant. "The symbol © (the letter C in a circle), or the word “Copyright,” or the abbreviation “Copr.”;" -- http://www.copyright.gov/circs/circ1.pdf[^]

          T Offline
          T Offline
          Tony Richards
          wrote on last edited by
          #4

          Not neccesarily: 'Some countries will not accept the symbol alone, they also require the word Copyright to appear in order to consider the notice valid. Using the word ensures that there can be no confusion.' http://www.copyrightservice.co.uk/copyright/p03_copyright_notices[^]

          P 1 Reply Last reply
          0
          • T Tony Richards

            Not neccesarily: 'Some countries will not accept the symbol alone, they also require the word Copyright to appear in order to consider the notice valid. Using the word ensures that there can be no confusion.' http://www.copyrightservice.co.uk/copyright/p03_copyright_notices[^]

            P Offline
            P Offline
            PIEBALDconsult
            wrote on last edited by
            #5

            Exactly, you only need the word. You use the symbol when there isn't enough room for the word.

            1 Reply Last reply
            0
            • R Ravi Sant

              This always works for me :) Hope it helps.

              StreamReader reader = new StreamReader(@"C:\FilePath\AssemblyInfo.cs");
              string contents = reader.ReadToEnd();
              reader.Close();

                      string NewCopyrightText = "Yippie. All rights reserved " + DateTime.Now.Year;
                      // replace assembly version
                      string replacement = "\[assembly: AssemblyCompany(\\"" + NewCopyrightText + "\\")\]";
                      contents = Regex.Replace(contents, @"\\\[assembly: AssemblyCompany\\("".\*""\\)\\\]", replacement);
                      
                      StreamWriter writer = new StreamWriter(@"C:\\FilePath\\AssemblyInfo.cs", false);
                      writer.Write(contents);
                      writer.Close();
              
              H Offline
              H Offline
              Helfdane
              wrote on last edited by
              #6

              Thanks for the suggestion, but I was looking for a method of accomplishing this without the overwrite of AssemblyInfo.cs.

              The consumer isn't a moron; she is your wife.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups