I find it very frustrating that there is no obvious way to have the .resx
generator mark members as public instead of internal. In my team's solution, we
have a need for these to be public. Here's how I solved it:
Add a nant target that can do a
find/replace in a file (I don't know of a shell command that will do that)
<?xml version="1.0" encoding="utf-8"?>
<!–EXTERNAL_PROPERTIES:
filename;stringToReplace;newString–>
<project name="BuildTasks" xmlns="http://nant.sf.net/release/0.85-rc4/nant.xsd">
<target name="FindReplace">
<move file="${filename}" tofile="${filename}.bak">
<filterchain>
<replacestring from="${stringToReplace}" to="${newString}" />
</filterchain>
</move>
<move file="${filename}.bak" tofile="${filename}"/>
</target>
</project>
Add a pre-build step to the project
to run this target and feed in the correct file:
pushd .
cd "$(ProjectDir)...."
binnantnant.exe -buildfile:buildtasks.build FindReplace -D:filename="$(ProjectDir)PropertiesIcons.Designer.cs" -D:stringToReplace=internal -D:newString=public
binnantnant.exe -buildfile:buildtasks.build FindReplace -D:filename="$(ProjectDir)PropertiesToolbarIcons.Designer.cs" -D:stringToReplace=internal -D:newString=public
popd
Compile as you normally would and
note the output:
------ Build started: Project: MyProject, Configuration: Debug Any CPU ------
pushd .
cd "C:svnMyProject-trunksrcMyProject...."
binnantnant.exe -buildfile:buildtasks.build FindReplace -D:filename="C:svnMyProject-trunksrcMyProject\PropertiesIcons.Designer.cs" -D:stringToReplace=internal -D:newString=public
binnantnant.exe -buildfile:buildtasks.build FindReplace -D:filename="C:svnMyProject-trunksrcMyProject\PropertiesToolbarIcons.Designer.cs" -D:stringToReplace=internal -D:newString=public
popd
NAnt 0.85 (Build 0.85.2344.0; rc4; 6/2/2006)
Copyright (C) 2001-2006 Gerry Shaw
http://nant.sourceforge.net
Buildfile: file:///C:/svn/MyProject-trunk/buildtasks.build
Target framework: Microsoft .NET Framework 2.0
Target(s) specified: FindReplace
FindReplace:
[move] 1 files moved.
[move] 1 files moved.
BUILD SUCCEEDED
Total time: 0 seconds.
NAnt 0.85 (Build 0.85.2344.0; rc4; 6/2/2006)
Copyright (C) 2001-2006 Gerry Shaw
http://nant.sourceforge.net
Buildfile: file:///C:/svn/MyProject-trunk/buildtasks.build
Target framework: Microsoft .NET Framework 2.0
Target(s) specified: FindReplace
FindReplace:
[move] 1 files moved.
[move] 1 files moved.
BUILD SUCCEEDED
Total time: 0 seconds.
Compile complete -- 0 errors, 0 warnings
MyProject -> C:svnMyProject-trunksrcMyProjectbinDebugMyProject.dll
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========