2

I'd like to add custom build parameters to to my C# .NET project but unfortunately I can set only limited settings in the Project -> Properties -> Build menu. Is there any option how to set custom parameters for my project? Even manual editing of csproj file is fine.

I've tried searching but the only results found are for C/C++ projects, that can be configured thoroughly in Visual Studio, or I should just use custom msbuild build script.

Thanks

2
  • response file is useful if you are working with csc.exe from command-line, but not configurable from VS. Commented Oct 7, 2014 at 14:49
  • What specific parameters are you looking for in C# compiler that is not available in VS project configuration page? Commented Oct 8, 2014 at 3:39

1 Answer 1

2

I've done by making an override of the C# target "CoreCompile" to pass LinkResources to the Csc task. I pulled it out into my own .targets file and included after Microsoft.CSharp.targets so that the same named targets override the standard targets.

In the project file, I created the LinkResource item group that included the files I needed.

<Target
    Name="CoreCompile"
    Inputs="$(MSBuildAllProjects);
            @(Compile);                               
            @(_CoreCompileResourceInputs);
            $(ApplicationIcon);
            $(AssemblyOriginatorKeyFile);
            @(ReferencePath);
            @(CompiledLicenseFile);
            @(EmbeddedDocumentation); 
            $(Win32Resource);
            $(Win32Manifest);
            @(CustomAdditionalCompileInputs);
            @(LinkResource)"
    ...>
    ...

    <Csc  Condition=" '%(_CoreCompileResourceInputs.WithCulture)' != 'true' "
          LinkResources="@(LinkResource)"
          ...
    />
    ...
</Target>

You could do it the same what if the Csc task supports the arguments that you need. If not, you could try overriding the Csc task.

Sign up to request clarification or add additional context in comments.

1 Comment

I guess creating my own .target file is the only solution here, thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.