-
Notifications
You must be signed in to change notification settings - Fork 654
added option to disable gitversiontask on build #1724
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added option to disable gitversiontask on build #1724
Conversation
i have no idea how to test this in the test project. I found no clue about testing setting build properties. i tried even to break the tests, with setting some properties in the .props file to random values, seems not be used at all 😄 |
You can run the project using http://msbuildlog.com/ and see the props and the targets that are used |
Didn't know that tool, but seems I'm not worthy ;) Also, i'm not familiar with creating Build Targets. I've run the build.ps1 is stopping on Pack-Gem because i don't have ruby, this can i comment out, but it is failing on other stuff. But this all only for one manual test. This is not a good idea. Currently i'm trying running msbuild in memory in the unit, that works, but have problems with adding the build targets. will check this out a little bit further. Or any other Ideas? |
I used that tool when I tested the changes I did when updated to Libgi2sharp 0.26.0. It's really easy to use it. |
I'm not against that tool, i search for the properties in the log, nothing found. i have to create a test project which includes the nuget package. and it is still a manual test. So i decided to give a unit test a try, so this is currently building. if the build now succeeds (worked with dotnet test, but not with nunit in the build script) I rebase that stuff. |
@DerAlbertCom I like the idea of how you tested the properties, I guess we might be using this approach for testing the tasks by running the msbuild the same way. These way we can cover the msbuild tasks as well. I gave a try the test locally with Visual studio test adapter as well as Resharper and the Unit test were failing on my machine. I can see they are also failing on the appveyor. I would suggest to make some small changes to the code so that the tests can run everywhere (VS + resharper) (bool failed, Project project) CallMsBuild(IDictionary<string, string> globalProperties)
{
var currentDirectory = AppDomain.CurrentDomain.BaseDirectory;
var projectXml =
$@"<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<Configuration>Debug</Configuration>
<GitVersionTaskRoot>{currentDirectory}\..\..\..\..\GitVersionTask\build\</GitVersionTaskRoot>
<GitVersionTaskRoot Condition=""!Exists('$(GitVersionTaskRoot)GitVersionTask.props')"">.\src\GitVersionTask\build\</GitVersionTaskRoot>
<GitVersionAssemblyFile>{currentDirectory}\..\..\GitVersionTask.MsBuild\bin\$(Configuration)\$(TargetFramework)\GitVersionTask.MsBuild.dll</GitVersionAssemblyFile>
</PropertyGroup>
<Import Project='$(GitVersionTaskRoot)GitVersionTask.props'/>
<Import Project='$(GitVersionTaskRoot)GitVersionTask.targets'/>
</Project>";
using (var stringReader = new StringReader(projectXml))
{
StringBuilder builder;
Project project;
bool result;
using (var collection = new ProjectCollection(globalProperties))
{
builder = new StringBuilder();
var writer = new StringWriter(builder);
void Handler(string x) => writer.WriteLine(x);
var logger = new ConsoleLogger(LoggerVerbosity.Quiet, Handler, null, null);
collection.RegisterLogger(logger);
XmlReader reader = new XmlTextReader(stringReader);
project = collection.LoadProject(reader);
result = project.Build();
collection.UnregisterAllLoggers();
}
var consoleOutput = builder.ToString();
Console.WriteLine(consoleOutput);
return (!result, project);
}
} |
- this is for #1723 - setting the DisableGitVersionTask property to true disables all activities if needed (e.g. NCrunch) - there is no conditional disabling in the .props file because it must have priority and simple disable it
- the ProjectCollection seems not supported on mono
- idea from #1724 (comment) - made the NUnit workaround obsolete
the change with the current directory at runtime made also the NUnit Test Run Workaround obsolete. If the tests failed on AppVeyour then the PR check did not really worked. |
@DerAlbertCom, I have integrated the changes in the props file, but left the tests out, looks like there are some issues with the tasks running in a unit test. I'll investigate that later. Thanks for your contribution. Please check this version |
Uh oh!
There was an error while loading. Please reload this page.