Reputation: 396
I have a Visual Studio ASP.NET C# Solution / Project setup like this:
> MySolution
> MyProject
* MyFolder
* MyPages
* MyScripts
...
MyConfig.cs <-- This file
...
--- End MyProject / MySolution
I am having the project compile, but in the process it also compiles the MyConfig.cs file too when I need it to not do so.
This file contains several properties in various forms that are used throughout the application and I would like it to be left in source code form so that it could be easily edited as plain text on the server if need be without rebuilding / redeploying the solution / project.
I have tried messing with the file's properties, specifically "Build Action" & "Copy to Output Directory", by setting them to "Content" and "Always", "Compile" and "Always", "AdditionalFiles" and "Always" ... respectively. All without success. I am not sure where I need to make changes in order to achieve this behavior.
Any assistance or help is appreciated.
Upvotes: 2
Views: 7460
Reputation: 66
You can just set the include tag to None like this:
<ItemGroup>
<None Include="foobar.cs" />
</ItemGroup>
Upvotes: 5
Reputation: 21
I know this is a bit old but after googling this for a while I found a solution so I thought I would post it here in case anyone else ends up reading this. I found this page but it did not work as described.
I opened my csproj file is a text editor and changed the “Include” to “Exclude”. The project would not load in VS because “Include” is required. So tried adding Include=”” along with the “Ecxclude” and the project still wouldn’t load.
So then I realized that you can use a Condition to resolve this.
<Compile Include="folder\blah.aspx.cs" Condition="1==2" />
Upvotes: 2
Reputation: 1160
Changing the build type to content or none should be sufficient but intellisense won't always catch that change. You will need to close the file first before you rebuild. You can reopen it afterwards and it should not be compiled or error checked in the editor anymore.
Upvotes: 1