visitAssemblyInfo()

in lib/generator.js [2952:2984]


  visitAssemblyInfo() {
    let propertiesDir = path.join(this.csprojOutputDir, 'Properties');
    if (!fs.existsSync(propertiesDir)) {
      fs.mkdirSync(propertiesDir, {
        recursive: true
      });
    }
    let assemblyPath = path.join(propertiesDir, 'AssemblyInfo.cs');
    let content = {};
    if (!fs.existsSync(assemblyPath)) {
      content = fs.readFileSync(path.join(__dirname, 'files', 'assemblyInfo.tmpl')).toString();
      let params = {
        title: this.config.packageInfo.title || '',
        description: this.config.packageInfo.description || '',
        company: this.config.packageInfo.company || '',
        product: this.config.packageInfo.product || '',
        guid: UUID.v1(),
        version: this.release.split(':')[1],
        copyRight: this.config.packageInfo.copyRight || '',
      };

      if (content !== '') {
        content = render(content, params);
      }
      fs.writeFileSync(assemblyPath, content);
    } else {
      content = fs.readFileSync(assemblyPath).toString();
      content = content.replace(/AssemblyVersion\("[\S\s].*?"\)/, `AssemblyVersion("${this.release.split(':')[1]}.0")`);
      content = content.replace(/AssemblyFileVersion\("[\S\s].*?"\)/, `AssemblyFileVersion("${this.release.split(':')[1]}.0")`);
      fs.writeFileSync(assemblyPath, content);
    }

  }