1
votes

If i create a project(with TargetFramework as netstandard2.0) using VS2017, the csproj automatically picks all the *.cs/folders copied to that directory and the csproj file doesn't contain any references to the *.cs files.

If i have to use command-line option MSBUILD to compile the project using the sln/csproj how do i do it ?Because the csproj doesn't contain the references to cs files.

Because the earlier csproj(created using vs2012) version would contain tag which would contain the list of files to compile,but with VS2017 the csproj file no longer contain those tags.

1
Provided you are using an up to date MSBuild, it will understand the new csproj format. Have you tried building? - DavidG
Agreed but if I want to exclude some of the files while building how do I do it - subbaraoc
You can still include files in the same way you did previously. Just do that and set the build action for the file. - DavidG
Ok you mean add the files in the csproj manually and build it? and what about the references?Will the msbuild pick it up automatically - subbaraoc
MSBuild will pick up all the file and build them. If you want to exclude a file from the build process you can add <ItemGroup><Compile Remove="SomeFile.cs" /></ItemGroup> - DavidG

1 Answers

2
votes

Provided you are using an up to date MSBuild, it will understand the new csproj format and include all the files automatically.

You can however still use ItemGroup in your csproj, this is especially useful if you want to prevent a file being compiled or want to give it special properties. For example, if you had a file called Foo.cs that you didn't want to be compiled as part of the library, you could add this to the csproj:

<ItemGroup>
    <Compile Remove="Foo.cs" />
</ItemGroup>