We're having issues with publishing. We use TFS to version the application. But there are two people doing the final publication (I do not accept that). Is there any way I go in Visual Studio and see the date of my last posting on my machine?
We're having issues with publishing. We use TFS to version the application. But there are two people doing the final publication (I do not accept that). Is there any way I go in Visual Studio and see the date of my last posting on my machine?
Okay, a simple way to create a log to write the date every time a Publish
is run is by changing the build process to generate a log file after the publish. Note that this file is being generated from your machine, so it only applies to the you publishes.
First of all, create a .targets file in the solution, in the project, wherever you prefer and with the name you prefer:
Thefileshouldcontainthefollowingcodeorsimilar:
<Projectxmlns="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 lets you understand what it does, it's a Target
that always executes after AfterPublish
, executing the specified code. I'm 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 stay in the root folder of the solution.
After saving this file, click "Unload Project" in your project, edit the file (edit command xxx.csproj), and add the following line at the end, still inside the Project
tag:
<Import Project="$(SolutionDir)postPublish.targets" />
This path will change depending on where you put the targets file you created. After doing a Publish
, the command will execute and will generate a log file with the date.
An important detail: If it is not a console / windows app / genre thing, maybe the name in AfterTargets
will change. Searching the internet or even browsing the msbuild logs you can easily know the name you need to use.