c# - How do I specify common source files and properties and have them appear in Visual Studio -
c# - How do I specify common source files and properties and have them appear in Visual Studio -
i have solution many projects share source files , properties. if set sources files in, instance, mutual .props file, source files impact build don't show in visual studio. short illustration is:
scratch.csproj:
<?xml version="1.0" encoding="utf-8"?> <project toolsversion="12.0" defaulttargets="build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <import project="$(msbuildextensionspath)\$(msbuildtoolsversion)\microsoft.common.props" condition="exists('$(msbuildextensionspath)\$(msbuildtoolsversion)\microsoft.common.props')" /> <itemgroup> <compile include="program.cs"/> </itemgroup> <import project="a.props" /> <import project="$(msbuildtoolspath)\microsoft.csharp.targets" /> </project>
a.props:
<project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <itemgroup> <compile include="a.cs"/> </itemgroup> </project>
a.cs, program.cs:
namespace scratch { public class {} }
this code not compile because class has been declared twice. however, file a.cs appears in visual studio solution. there prepare can have shared properties , source files appear in solution? saw 1 possibility beingness instead of a.props, using a.csproj , adding solution. however, has problems. if instead on using of properties project (depending on conditions set), won't clear source file or property goes project.
visual studio doesn't deal total flexibility of msbuild files. builds work because visual studio invokes msbuild libraries project designers, solution explorer, etc can't represent things haven't been designed for.
the mutual way include shared source (that is, if don't create separate project of it), add together files project links: add together exiting item..., select files, , instead of clicking button, click arrow on right side of button , adds links. solution explorer designed recognize linked files.
properties should fine in shared import file note visual studio doesn't recognize changes imports; have reload project manually.
c# visual-studio msbuild
Comments
Post a Comment