Okay, a simple way to create a log to record the date every time a Publish
run is by changing the build process to generate a log file after Publish. Note that this file is being generated from your machine, so it is only valid for publishes that you carry out.
First of all, create a . targets file in the solution, in the project, where you prefer and with the name you prefer:
The file must contain the following code or similar:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="CustomPublish" AfterTargets="AfterPublish" >
<ItemGroup>
<LogFile Include="$(SolutionDir)log.txt"/>
<DateTimeNow Include="data1">
<Text>
$([System.DateTime]::Now)
</Text>
</DateTimeNow>
</ItemGroup>
<WriteLinesToFile
File="@(LogFile)"
Lines="@(DateTimeNow->'%(Text)')"
Overwrite="true"
Encoding="Unicode"/>
</Target>
I think reading can understand what he does, is a Target
that always runs after the AfterPublish
, executing the specified code. I am setting the current time/date (which will be the time/date of the publication) to a variable and writing to a file called log.txt, which will be in the root folder of the solution.
After saving this file, click "Unload Project" in your project, edit the file (Command Edit xxx.csproj), and add the following line at the end, still inside the tag Project
:
<Import Project="$(SolutionDir)postPublish.targets" />
This path will change depending on where you put the targets file you created. After you do a Publish
, the command will be executed and will generate a log file with the date.
One important detail: If it’s not a console/windows app/genre thing, maybe the name on AfterTargets
change. Searching the internet or even searching in the msbuild logs you can easily know the name you will need to use.
Right click on the solution -> Source Control -> View History ??
– CesarMiguel
@Cesarmiguel, But History does not show the date of the last Publish. It shows the history of TFS, but Publish it does not show.
– pnet
and if you actually go to the TFS website?
– CesarMiguel
If the publications are made only from a Publish in the visual studio, I believe there is no way to know. If so, I suggest removing write permission from the respective(s) resource(s) that is(m) posting improperly to the respective(s) server(s). Now if you’re using Team Build to do.
– Conrad Clark
@Conradclark, I don’t publish directly into a folder and then move up to the right environments. I don’t use team build.
– pnet
It is possible to withdraw these people’s permission for this
pasta
? If you really need to know when was the last time you published from your machine, I think you can include an extra step after Publish to record the current date in a file or some sort of log. If you want details on how to do that, I can answer the question.– Conrad Clark
@Conradclark, you can answer the question. I need to do this
– pnet