npm-tfs-unlock package on TFS - c#

I have a problem with a npm package the tfs-unlock (I'm using grunt)
This is the message that I get from server when trying to build.
[exec] [4mRunning "tfs-unlock:checkout" (tfs-unlock) task[24m
[exec] [31m>> [39mChild process exited with code # 1.
[exec] [33mWarning: Task "tfs-unlock:checkout" failed. Use --force to continue.[39m
[exec]
[exec] [31mAborted due to warnings.[39m
and this is the configuration of the task
'tfs-unlock': {
'checkout': {
'options': {
'tfsPath': ["vs2013", "bit64"],
'action': 'checkout'
},
'files': {
'src': ['js/*.js', 'js/*.min.js', 'css/*.css']
}
}
}
Has anyone who used it, have had this issue? if so, why this error appears? how to make it work?
Thank you
PS: locally works perfect, it does not complain of anything.
I'm using Jenkins and Octopus for automatic build and deploy.
When Jenkins builds, changes should be applied (this is the step where the "tfs-unlock:checkout" fails says that the "checkout child" does not exist, when clearly it does exist , how else could this work locally right?)
I'm working behind a PROXY but to handle this I use this file which is targeted by an Ant step
my.xml configuration
<target name="build" description="generate files with grunt">
<exec executable="cmd" dir="./" failonerror="true">
<arg value="/C" />
<arg value="npm"/>
<arg value="config"/>
<arg value="set"/>
<arg value="proxy"/>
<arg value="http://my_Address/"/>
<arg value="--global"/>
</exec>
<echo message="Installing Deps ..." />
<exec executable="cmd" dir="./" failonerror="true">
<arg value="/C" />
<arg value="npm"/>
<arg value="install"/>
</exec>
<echo message="generate files..." />
<exec executable="cmd" dir="./" failonerror="true">
<arg value="/C" />
<arg value=".\node_modules\.bin\grunt" />
</exec>
<echo message="Done" />
</target>

First, please make sure your configuration and option with grunt-tfs-unlock is correct without any problem. Details please refer this link grunt-tfs-unlock
Moreover, if it's still not wrok. You can also use the workaround--using the grunt-shell task which leaves you more in charge of the configuration.
Here is a example of using TFS check out with Grunt. This link demonstrates the 'tf checkout' command. However you could also create any other tf command with this pattern.

Related

Using Msbuild variables in Project Extensions

I currently have a solution with a web.api project that I want to deploy to different virtual directories in my local IIS. Currently I am doing the following in the .csproj of the api:
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)' == 'CustomerOne.Debug'">
<CustomerName>CustomerOne</CustomerName>
....
</PropertyGroup>
...
These variables are used extenisvely further on for web.config transforms, copying to different locations, etc., by referencing them like $(CustomerName).
The only place where it does not work is in the definition of the virtual directory, i.e., I'd like to connect the build configuration to the IISUrl below, which you can hardcode:
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
...
<IISUrl>http://localhost/api/something</IISUrl>
...
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
Replacing this by <IISUrl>http://localhost/api/$(CustomerName)</IISUrl> does not work. Ideas?
Replacing this by http://localhost/api/$(CustomerName) does not work. Ideas?
That because Anything inside of a ProjectExtensions element will be ignored by MSBuild.
You can get the detailed info from this document ProjectExtensions Element (MSBuild):
Allows MSBuild project files to contain non-MSBuild information.
Anything inside of a ProjectExtensions element will be ignored by
MSBuild.
That is the reason why the Msbuild variables not work in Project Extensions.
Hope this helps.
You could update the underlying project file. A Target like this in your project file would do it.
<Target Name="AfterBuild">
<PropertyGroup>
<NewUrl>http://localhost/api/$(CustomerName)</NewUrl>
</PropertyGroup>
<Message Text="Updating IISUrl: $(NewUrl) in $(MSBuildProjectFile)" />
<XmlPeek Namespaces="<Namespace Prefix='msb' Uri='http://schemas.microsoft.com/developer/msbuild/2003'/>" XmlInputPath="$(MSBuildProjectFile)" Query="/msb:Project/msb:ProjectExtensions/msb:VisualStudio/msb:FlavorProperties/msb:WebProjectProperties/msb:IISUrl/text()">
<Output TaskParameter="Result" ItemName="Peeked" />
</XmlPeek>
<Message Text="Current Url: #(Peeked)" />
<!-- Only update the IISUrl if its changed -->
<XmlPoke Condition=" '#(Peeked)'!='$(NewUrl)' " XmlInputPath="$(MSBuildProjectFile)" Namespaces="<Namespace Prefix='msb' Uri='http://schemas.microsoft.com/developer/msbuild/2003'/>" Query="/msb:Project/msb:ProjectExtensions/msb:VisualStudio/msb:FlavorProperties/msb:WebProjectProperties/msb:IISUrl" Value="$(NewUrl)" />
</Target>
However it does have side affects. Changing the underlying project file means Visual Studio decides it should reload the project.
To use it you cannot go directly into Debug. Instead build, reload the project and then go into debug. If you go directly into Debug (with a compile) it will use the old url.

Change AssemblyName via MSBuild Target

I am trying to configure an MSBuild target, in my Project.csproj file. The target, called "Test" is called with the following command:
msbuild.exe /target:Test
However, I cannot figure out how to change the AssemblyName (original assembly name is MyProject), for this target. My code looks like this:
<Target Name="Test">
<PropertyGroup>
<PublishUrl>D:\PublishLocation\ClickOnce Setup\</PublishUrl>
</PropertyGroup>
<MSBuild Projects="$(ProjLocation)\$(ProjectName).csproj" Properties="ProductName=$(ProductName) (Test); AssemblyName=MyProjectTest; PublishUrl=$(PublishUrl)" Targets="Publish" />
<ItemGroup>
<SetupFiles Include="$(ProjPublishLocation)\*.*" />
<UpdateFiles Include="$(ProjPublishLocation)\Application Files\**\*.*" />
</ItemGroup>
<Copy SourceFiles="#(SetupFiles)" DestinationFolder="D:\PublishLocation\ClickOnce Setup\" />
<Copy SourceFiles="#(UpdateFiles)" DestinationFolder="D:\PublishLocation\ClickOnce Setup\Application Files\%(RecursiveDir)" />
</Target>
If I remove the AssemblyName=MyProjectTest; from the code, it works fine. If I run it as above, I get the following error:
"C:\Users\...\MyProject\MyProject.csproj"
(Test target) (1) ->
"C:\Users\...\MyProject\MyProject.csproj"
(Publish target) (1:2 ) ->
(CoreCompile target) ->
Models\SessionModel.cs(207,51): error CS1528: Expected ; or = (cannot
specify constructor arguments in declaration) [
C:\Users\...\MyProject\MyProject.csproj]
(...and a lot more, which is more or less the same)
UPDATE
I found some more, perhaps more interesting, warnings in the build output:
"C:\Users\...\MyProject\MyProject.csproj"
(Fast target) (1) ->
"C:\Users\...\MyProject.csproj"
(Publish target) (1:2 ) -> (ResolveAssemblyReferences target) ->
C:\Program Files
(x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1820,5):
warning MSB3277:
Found conflicts between different versions of the
same dependent assembly that could not be resolved. These reference
conflicts a re listed in the build log when log verbosity is set to
detailed. [C:\Users\...\MyProject\MyProject.csproj]
It might be worth mentioning, that I have older versions published in the publish location, in which the assembly name was not changed. Can this cause the conflict I see...?
Change AssemblyName via MSBuild Target
According to your Test target and another post, I have created a sample app to test this issue with following scripts and MSBuild command line msbuild.exe /target:Test:
<PropertyGroup>
<ProjLocation>$(ProjectDir)</ProjLocation>
<ProjLocationReleaseDir>$(ProjLocation)\bin\Debug</ProjLocationReleaseDir>
<ProjPublishLocation>$(ProjLocationReleaseDir)\app.publish</ProjPublishLocation>
<DeploymentFolder>D:\PublishFolder\Test\</DeploymentFolder>
</PropertyGroup>
<Target Name="Test" DependsOnTargets="Clean">
<MSBuild Projects="$(ProjLocation)\$(ProjectName).csproj" Properties="ProductName=$(ProductName) (Test); AssemblyName=MyProjectTest; PublishUrl=$(PublishUrl)" Targets="Publish" />
<ItemGroup>
<SetupFiles Include="$(ProjPublishLocation)\*.*" />
<UpdateFiles Include="$(ProjPublishLocation)\Application Files\**\*.*" />
</ItemGroup>
<Copy SourceFiles="#(SetupFiles)" DestinationFolder="$(DeploymentFolder)\Public Test\" />
<Copy SourceFiles="#(UpdateFiles)" DestinationFolder="$(DeploymentFolder)\Public Test\Application Files\%(RecursiveDir)" />
</Target>
It works fine without any issue, and assembly name was also changed:
So this issue should be more related to the error CS1528 in the SessionModel.cs file and warning MSB3277. To resolve the CS1528 error, you can check the document Compiler Error CS1528 for some more details.
And for the warning MSB3277, you can change the "MSBuild project build output verbosity" to "Detailed" to check the reference conflicts and resolve this conflicts. you can see this thread for some details.
Hope this helps.
It turns out the problem was, that I had included System.net.http.dll as a file in my project. This was set to Content as build actions. When I changed it to Embedded resource, it started working.

Unable to Uninstall WiX Managed Bootstrapper application from another Managed Bootstrapper Application

I have my own Managed Bootstrapper Application developed using WiX Toolset and written in c# using MVVM pattern. As this is a Managed Bootstrapper Application, i have a custom UI as well. My Bundle.wxs Code is as follows
<Bundle Name="NestleMESSetup"
Version="!(bind.packageVersion.NestleCustomLayerSetupPackage)"
Manufacturer="CT Infotech"
UpgradeCode="CCBB8D5B-8171-47FB-AD53-25C6E866C34E"
Copyright="Copyright© 2017 CT Infotech ALL RIGHTS RESERVED"
SplashScreenSourceFile="Resources\Splash.bmp"
IconSourceFile="Resources\menu.ico">
<Variable Name="KambanVersion" Type="version" Value="!(bind.packageVersion.KambanFASSetup)"/>
<BootstrapperApplicationRef Id="ManagedBootstrapperApplicationHost">
<PayloadGroupRef Id="InstallerPayload"/>
</BootstrapperApplicationRef>
<util:RegistrySearchRef Id='SearchForKamban' />
<Chain>
<PackageGroupRef Id="InstallerPackages"/>
</Chain>
<Variable Name="DbName" bal:Overridable="yes" />
<Variable Name="SqlInstance" bal:Overridable="yes" />
<Variable Name="InstallPath" bal:Overridable="yes" />
<Variable Name="Roles" bal:Overridable="yes" />
<Variable Name="Modules" bal:Overridable="yes" />
<Variable Name="CustomInstall" bal:Overridable="yes"/>
<WixVariable Id="WixMbaPrereqPackageId" Value="Netfx4Full" />
<WixVariable Id="WixMbaPrereqLicenseUrl" Value="NetfxLicense.rtf" />
</Bundle>
<Fragment>
<PayloadGroup Id="InstallerPayload">
<Payload SourceFile="..\Nestle.MES.Bootstrapper.UI\BootstrapperCore.config"/>
<Payload SourceFile="..\Nestle.MES.Bootstrapper.UI\bin\$(var.Configuration)\Nestle.MES.Bootstrapper.UI.dll"/>
<Payload SourceFile="C:\Program Files (x86)\WiX Toolset v3.10\SDK\Microsoft.Deployment.WindowsInstaller.dll"/>
</PayloadGroup>
</Fragment>
<Fragment>
<PackageGroup Id="InstallerPackages">
<RollbackBoundary Id="StartingPoint" Vital="yes" />
<ExePackage Id="KambanFASSetup" Cache="no" Compressed="yes" Vital="yes" Permanent="no" Name="KambanCoreSetup"
SourceFile="..\..\Kamban.FAS.Setup_Source\$(var.Configuration)\KambanFASSetup.exe" >
<CommandLine InstallArgument="[SqlInstance]" Condition="1" />
<CommandLine InstallArgument="[DbName]" Condition="1"/>
<CommandLine InstallArgument="[InstallPath]" Condition="1"/>
<CommandLine InstallArgument="[Roles]" Condition="1"/>
<CommandLine InstallArgument="[Modules]" Condition="1" />
<CommandLine InstallArgument="[CustomInstall]" Condition="1"/>
</ExePackage>
<MsiPackage SourceFile="..\..\build_folder\$(var.Configuration)\Nestle.MES.CustomLayer\Nestle.MES.CustomLayerSetup.msi"
Id="NestleCustomLayerSetupPackage" Cache="yes" Visible="no" Compressed="yes" EnableFeatureSelection="yes" Vital="yes">
<MsiProperty Name="INSTALLFOLDER" Value="[INSTALLFOLDER]" />
<MsiProperty Name="VERSION" Value="[VERSION]"/>
<MsiProperty Name="ADDLOCAL" Value="[NestleFeatures]" />
</MsiPackage>
</PackageGroup>
</Fragment>
<Fragment>
<util:RegistrySearch
Id='SearchForKamban'
Variable="KambanInstalled"
Result="exists"
Root="HKLM"
Key="SOFTWARE\Wow6432Node\KambanFAS" />
<bal:Condition Message="Product already Exists">
KambanInstalled
</bal:Condition>
</Fragment>
In the above code, you can see that I have an MsiPackage and an ExePackage in my Bundle chain. The ExePackage with Id="KambanFASSetup" is also a Managed Bootstrapper Application with its very own custom UI. Once I install this Parent bundle exe, i get two entries in my Programs and Features. I believe this is because i have two managed bootstrapper exe. So now while uninstalling the NestleMESSetup only my MsiPackage is getting uninstaled and my ExePackage doesnt. But my requirement is as follows
The ExePackage should also be uninstalled if I uninstall the Parent Exe.
The Uninstallation of the Child ExePackage must happen silently. i.e
It's UI should NOT be shown prompting the user to click the Uninstall
button again.
Please let me know if more info is needed.Any help on this would be much appreciated.
Edit1:
Here is the Uninstall logs in %temp% folder
[2658:3330][2017-05-19T19:27:11]i001: Burn v3.10.2.2516, Windows v6.1 (Build 7601: Service Pack 1), path: C:\ProgramData\Package Cache\{a21ebf3e-08b2-4b64-b5bf-38dccfea21a2}\Nestle.MES.Setup.exe
[2658:3330][2017-05-19T19:27:11]i000: Initializing version variable 'KambanVersion' to value '1.0.647.0'
[2658:3330][2017-05-19T19:27:11]i009: Command Line: '/uninstall'
[2658:3330][2017-05-19T19:27:11]i000: Setting string variable 'WixBundleLog' to value 'C:\Users\RAJASA~1.000\AppData\Local\Temp\NestleMESSetup_20170519192711.log'
[2658:3330][2017-05-19T19:27:11]i000: Setting string variable 'WixBundleManufacturer' to value 'CT Infotech'
[2658:3330][2017-05-19T19:27:11]i000: Loading managed bootstrapper application.
[2658:3330][2017-05-19T19:27:11]i000: Creating BA thread to run asynchronously.
[2658:3330][2017-05-19T19:27:11]i100: Detect begin, 2 packages
[2658:3330][2017-05-19T19:27:11]i000: Setting numeric variable 'KambanInstalled' to value 1
[2658:3330][2017-05-19T19:27:11]i101: Detected package: KambanFASSetup, state: Absent, cached: None
[2658:3330][2017-05-19T19:27:11]i101: Detected package: NestleCustomLayerSetupPackage, state: Present, cached: Complete
[2658:3330][2017-05-19T19:27:11]i104: Detected package: NestleCustomLayerSetupPackage, feature: AppFeatures, state: Local
[2658:3330][2017-05-19T19:27:11]i104: Detected package: NestleCustomLayerSetupPackage, feature: WebFeatures, state: Local
[2658:3330][2017-05-19T19:27:11]i104: Detected package: NestleCustomLayerSetupPackage, feature: DbFeatures, state: Local
Edit2:
With the Detect Condition added to my Bundle chain Exe package I am not able to Uninstall the Parent exe as well. The WiX logs are as follows
[1450:1BBC][2017-05-20T07:33:59]i371: Updating session, registration key: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{c8fb8ef8-905f-4bd9-8675-91f62d83e5c8}, resume: Active, restart initiated: No, disable resume: No
[1644:0F04][2017-05-20T07:33:59]w341: Prompt for source of container: WixAttachedContainer, path: E:\TFS_Nestle\Nestle\build_folder\Debug\Nestle.MES.Setup\Nestle.MES.Setup.exe
[1644:0F04][2017-05-20T07:33:59]e054: Failed to resolve source for file: E:\TFS_Nestle\Nestle\build_folder\Debug\Nestle.MES.Setup\Nestle.MES.Setup.exe, error: 0x80070002.
[1644:0F04][2017-05-20T07:33:59]e000: Error 0x80070002: Failed while prompting for source (original path 'E:\TFS_Nestle\Nestle\build_folder\Debug\Nestle.MES.Setup\Nestle.MES.Setup.exe'). [1644:0F04][2017-05-20T07:33:59]e311: Failed to acquire container: WixAttachedContainer to working path: C:\Users\RAJASA~1.000\AppData\Local\Temp\{B5BE6652-F453-40B5-A2BF-6313B191EA7F}\9FD1B9E707102B3EB2E75EA87962C5C839E9588A, error: 0x80070002.
[1644:1B24][2017-05-20T07:33:59]e000: Error 0x80070002: Failed while caching, aborting execution.
[1450:1BBC][2017-05-20T07:33:59]i372: Session end, registration key: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{c8fb8ef8-905f-4bd9-8675-91f62d83e5c8}, resume: ARP, restart: None, disable resume: No
[1450:1BBC][2017-05-20T07:33:59]i371: Updating session, registration key: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{c8fb8ef8-905f-4bd9-8675-91f62d83e5c8}, resume: ARP, restart initiated: No, disable resume: No
[1644:1B24][2017-05-20T07:33:59]i399: Apply complete, result: 0x80070002, restart: None, ba requested restart: No
[1644:1B24][2017-05-20T07:33:59]i500: Shutting down, exit code: 0x0
Your ExePackage is missing the UninstallCommand attribute so burn does not know how to properly uninstall it. It should be something like
UninstallCommand="/uninstall /quiet"
and may be some additions if needed.
And for burn to be able to detect the ExePackage, it should define the attribute DetectCondition. Something like
DetectCondition="KambanInstalled"

MSBuild: Ensure a target is run before any other build steps

I am trying to have the AssemblyInfo.cs file updated to reflect the next Publish version of the project BEFORE any other build steps occur.
in my project file i added before the end:
<Import Project="$(ProjectDir)Properties\PublishVersion.proj" />
PublishVersion.proj looks like this:
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
<Target Name="BeforeBuild">
<FormatVersion Version="$(ApplicationVersion)" Revision="$(ApplicationRevision)">
<Output TaskParameter="OutputVersion" PropertyName="SetVersion" />
</FormatVersion>
<FileUpdate Files="$(ProjectDir)Properties\AssemblyInfo.cs"
Regex="\d+\.\d+\.\d+\.\d+"
ReplacementText="$(SetVersion)" />
</Target>
</Project>
Now it does execute somewhere before building completes but definitely not before it starts, because when i look at the generated exe it has a file version that was in AssemblyInfo.cs BEFORE build started but the .application file and manifest file have various references to the new version.
resulting manifest file(1.0.0.0 before build start, 1.0.0.4 after build):
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly ...>
<asmv1:assemblyIdentity name="BHTechSupport.exe" version="1.0.0.4" ... />
...
<entryPoint>
<assemblyIdentity name="BHTechSupport" version="1.0.0.0" ... />
...
</entryPoint>
...
<dependency>
<dependentAssembly ... codebase="BHTechSupport.exe" ...>
<assemblyIdentity name="BHTechSupport" version="1.0.0.0" ... />
...
</dependentAssembly>
</dependency>
...
</asmv1:assembly>
so how do i ensure that my target gets executed before EVERYTHING else?
making changes to PublishVersion.proj sometimes seem to not take effect and i need to clean the solution and restart visual studio before effecting.
Maybe you have to use BeforeBuild target.
so how do i ensure that my target gets executed before EVERYTHING
else?
To check your target execution, you can change the MSBuild project build output verbosity to Diagnostic. Find it under the Tools > Options > Projects and Solutions > Build and Run. Then build the project and find your target in the output window.
making changes to PublishVersion.proj sometimes seem to not take
effect and i need to clean the solution and restart visual studio
before effecting.
AFAIK, the Visual Studio loads target files once, so you have to reload your project to see the result.
Update I don't know your versioning system, whereas it's not important. Anyway, I tried to provide a simple example for you.
using System;
using System.IO;
using Microsoft.Build.Utilities;
using Microsoft.Build.Framework;
namespace Foo.Build.Tasks {
public sealed class GenerateVersion : Task {
[Output]
public ITaskItem[] GeneratedFiles { get; private set; }
public override bool Execute() {
string objPath = Path.Combine(Path.GetDirectoryName(this.BuildEngine3.ProjectFileOfTaskNode), "obj");
string path = Path.Combine(objPath, "VersionInfo.cs");
File.WriteAllText(path, #"using System.Reflection;
[assembly: AssemblyVersion(""2.0.0"")]");
GeneratedFiles = new[] { new TaskItem(path) };
return true;
}
}
}
The preceding task generates a file that contains AssemblyVersion metadata or everything you want.
At last, you have to change your project file as follows:
<UsingTask TaskName="Foo.Build.Tasks.GenerateVersion" AssemblyFile="Foo.Build.Tasks.dll" />
<Target Name="BeforeBuild">
<GenerateVersion>
<Output TaskParameter="GeneratedFiles" ItemName="Compile" />
</GenerateVersion>
</Target>
If you want a target to run at the beginning of every build regardless of what end-goal target is called (Clean, Restore, Build, Publish) you can use the InitialTargets attribute of the Project element.

Building sub projects using NANT

I'm trying to build a project(A) using NANT. The project(A) relies upon another project(B) which is also built with NANT. I want to be able to invoke the build of the dependent project(B) from within the build of project(A). I've tried including the build file of project B in the build file of project A. This creates an error because the two build files contain targets that share the same name.
Is there a way to alias the included build file?
You can do it like this by creating a "parent" buildfile, that uses the "nant" action to call other buildfiles.
<target name="rebuild" depends="" >
<nant target="${target::get-current-target()}">
<buildfiles>
<include name="projectB.build" />
<include name="projectC.build" />
</buildfiles>
</nant>
</target>
I was trying to do this using an include task but have found that the nant task is actually what I required.
You can have several of such targets in your 'master' file. I often use the following construction to share a set of build files between targets to make script maintenance easier.
<fileset id="buildfiles.all">
<include name="projectB.build"/>
<include name="projectB.build"/>
</fileset>
<target name="build">
<nant target="${target::get-current-target()}">
<buildfiles refid="buildfiles.all" />
</nant>
</target>
<target name="clean">
<nant target="${target::get-current-target()}">
<buildfiles refid="buildfiles.all" />
</nant>
</target>
<target name="publish">
<nant target="${target::get-current-target()}">
<buildfiles refid="buildfiles.all" />
</nant>
</target>

Categories

Resources