CodeJingle

Hey I have this C# project (.csproj extension).  I want to have it always rebuild every time, regardless.  How do I do that   Is there a flag or something I can manually throw into the project file (xml tag)

Re: Visual C# IDE How to always force rebuild C# project?

Mark Benningfield

Hello All.

CodeJingle:

I'm afraid I don't quite follow. Rebuild every time -- when, and regardless -- of what






Re: Visual C# IDE How to always force rebuild C# project?

CodeJingle

Every time the project gets built it will rebuild the whole thing.  My specific context would be building from the command line, but that doesn't really matter.

Think of it as a permanent date mismatch.  If the dates of code files are more recent than the binary (every time the project gets built), well then the project will always be fully rebuilt.

I'm really just looking for an xml tag to throw in the .csproj xml file (MS-Build or whatever it is).





Re: Visual C# IDE How to always force rebuild C# project?

Mark Benningfield

Hello All.

CodeJingle:

I guess we're still not on the same page. Are you saying that when you build your project, it doesn't reflect saved changes in the source files






Re: Visual C# IDE How to always force rebuild C# project?

CodeJingle

That is basically what I want to happen.  I want to tell the compiler (for a specific project) to ignore whether or not it is up-to-date and just rebuild it.  So every time the project gets built it is instead rebuilt.



Re: Visual C# IDE How to always force rebuild C# project?

Mark Benningfield

Hello All.

CodeJingle:

Er, well, if there have been zero changes to the source files, then you would wind up with the exact same MSIL code anyway. So, then, what are you trying to gain






Re: Visual C# IDE How to always force rebuild C# project?

CodeJingle

One project is overwriting another one's binaries.

I think you get what I want here, even if you don't understand why I want it.  Really though is there a way to accomplish this with some kind of flag in the .csproj xml file

Think of it as a challenge!





Re: Visual C# IDE How to always force rebuild C# project?

Mark Benningfield

Hello All.

CodeJingle:

Alas, you weren't quite quick enough with the edit. I read you last post before then. Sorry if you feel I was wasting your time. Shan't happen again. Good luck.

HTH.






Re: Visual C# IDE How to always force rebuild C# project?

Gabriel Lozano-Moran

As I understand it what you want is a plain old simple "Rebuild Solution" which is basically a "Clean Solution" (purges the contents in the \debug or \release subfolders) followed by a "Build Solution". That would be a devevn.exe /rebuild from the command-line.

And if I got it wrong well then instead of telling us in a subtle manner to stop wasting your time you could clarify what you want exactly without the gibberish posts.






Re: Visual C# IDE How to always force rebuild C# project?

Peter Ritchie

"Built" when During debug, when "Build Solution" is selected, when "Build" is selected...




Re: Visual C# IDE How to always force rebuild C# project?

CodeJingle

Whenever devenv is called on the project to build it.

Ok well that is a good point.  Lets say for simplicity sake that there is only one project.  There isn't even a solution file (though an .sln file will be auto-generated every time you open the project in Visual Studio).

project.csproj

code.cs

 

One project file and one code file.  The output of running the build process on the project will result in (among other things) a dll.





Re: Visual C# IDE How to always force rebuild C# project?

CodeJingle

I can't touch the build scripts, all I can do is edit the .csproj file.  Again all I'm looking for is some xml to throw in the .csproj file that will guarantee a rebuild every time the project is built.

Now I figure I can add a pre-build event that just calls 'devenv project.csproj /clean' on the project.  So I guess thanks to Gabriel Lozano-Moran for the great idea.

So the answer turned out to be quite obvious.  I'm not taking the best route but it will be fun to try out.





Re: Visual C# IDE How to always force rebuild C# project?

CodeJingle

Again the answer was quite obvious and simple. So much in fact I felt a little silly. I couldn't be frank or obvious because of the nature of the work ... subtle-ness was a necessity. Being an experienced industry programmer all I usually need is a single example and can take it from there.

It was hard to get those listening to let go of needing to know 'why' (asking me over and over why why 'why are you asking this question it doesn't make any sense why you would want to do this'). All I needed was the 'how'. Yes and in a sense the constant un-necessary 'why' questions were a waste of everyone's time. I still got my question answered, despite my being a smidgen too honest.

If somone offers a million dollars to answer a question and they won't say why they are asking it, would people still refuse to answer it Though I wasn't offering a million dollars Smile

So adding a 'PreBuildEvent' to the '.csproj' file of the project would be one possible attempt at a self-forcing every-time rebuild. And it was pointed out that may be affected by the build hierarcy of the product in question, but then I asked everyone to make the assumption that I was only concerned with a build entirely composed of a single '.csproj' file.

<PreBuildEvent>

devenv project.csproj /Clean

</PreBuildEvent>





Re: Visual C# IDE How to always force rebuild C# project?

Peter Ritchie

You realize that performing a clear in a post-build event will result in the deletion of the file (or files) you just built




Re: Visual C# IDE How to always force rebuild C# project?

CodeJingle

The follys of copy/paste. PreBuildEvent rather