Automatic regenerate designer files

前端 未结 3 1270
轮回少年
轮回少年 2021-02-07 13:57

Recently I\'ve been making some improvements to a lot of the controls we use, for example give properties default values and making buttons private instead of protected. By maki

3条回答
  •  时光说笑
    2021-02-07 14:24

    I also ran into this problem (see also: Force WinForms to regenerate .designer.cs files).

    In the end, most of the properties I removed were uniquely named, and I was able to write a shell script to remove lines from the designer files that contained the property names.

    Note, this actually removes the line, not just leaving a blank line.
    It needs to be run from a Bash Shell, if you have msysgit installed, that shell is fine.
    In this one, TextForeColor was the property being removed.

    #!/bin/bash
    files=$(find . -type f -name '*.Designer.cs' -print0 | xargs -0 grep -l 'TextForeColor')
    for file in $files
    do
        echo $file
        sed '/TextForeColor/ d' $file >$file.tmp
        mv $file.tmp $file
    done
    

提交回复
热议问题