Skip to content
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

Msbuild.version #30

Merged
merged 4 commits into from
Jul 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 26 additions & 9 deletions src/Metropolis.Api/IO/UserPreferences.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
using Metropolis.Api.IO.AutoSave;
using System;
using System.IO;
using System.Linq;
using Metropolis.Api.Properties;

namespace Metropolis.Api.IO
{
public class UserPreferences : IUserPreferences
{
string _msBuildPath;

public bool ShowTipOfTheDay
{
get { return (bool) Settings.Default["ShowTips"]; }
get { return (bool)Settings.Default["ShowTips"]; }
set
{
Settings.Default["ShowTips"] = value;
Expand All @@ -17,7 +21,7 @@ public bool ShowTipOfTheDay

public string FxCopPath
{
get { return (string) Settings.Default["FxCopPath"]; }
get { return (string)Settings.Default["FxCopPath"]; }
set
{
Settings.Default["FxCopPath"] = value;
Expand All @@ -27,13 +31,26 @@ public string FxCopPath

public string MsBuildPath
{
get { return (string) Settings.Default["MsBuildPath"]; }

set
get
{
Settings.Default["MsBuildPath"] = value;
Settings.Default.Save();
if (_msBuildPath == null)
InitMsBuildPath();

return _msBuildPath ?? Settings.Default.MSBuildPathFallback;
}

set { _msBuildPath = value; }
}

void InitMsBuildPath()
{
var paths = Environment.GetEnvironmentVariable("PATH")?.Split(';');
var msbuildExe = "msbuild.exe";

var msBuildDirectory = paths?.FirstOrDefault(path => FileExists(path, msbuildExe));
_msBuildPath = Path.Combine(msBuildDirectory, msbuildExe);
}

bool FileExists(string path, string file) => File.Exists(Path.Combine(path.Trim(), file));
}
}
}
2 changes: 1 addition & 1 deletion src/Metropolis.Api/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/Metropolis.Api/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<Setting Name="ShowTips" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="MSBuildPath" Type="System.String" Scope="User">
<Setting Name="MSBuildPathFallback" Type="System.String" Scope="User">
<Value Profile="(Default)">C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe</Value>
</Setting>
<Setting Name="FxCopPath" Type="System.String" Scope="User">
<Value Profile="(Default)">C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\FxCop\metrics.exe</Value>
</Setting>
</Settings>
</SettingsFile>
</SettingsFile>
2 changes: 1 addition & 1 deletion src/Metropolis.Api/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<setting name="ShowTips" serializeAs="String">
<value>True</value>
</setting>
<setting name="MSBuildPath" serializeAs="String">
<setting name="MSBuildPathFallback" serializeAs="String">
<value>C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe</value>
</setting>
<setting name="FxCopPath" serializeAs="String">
Expand Down
8 changes: 6 additions & 2 deletions src/Metropolis.Cli.Console/Metropolis.Console.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@
<Name>Metropolis.Common</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Content Include="NLog.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
</Project>
3 changes: 1 addition & 2 deletions src/Metropolis.Cli.Console/MetropolisCLI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ private static void Main(string[] args)
else
{
System.Console.WriteLine("Metropolis expects you to have the following parameters: pathOfYamlConfigFile pathToProjectResultFile");
System.Console.WriteLine(@"eg: metropolis.exe c:\ProjectFolder\project.yml c:\ProjectFolder\Results");
System.Console.WriteLine(@"eg: metro.exe c:\ProjectFolder\project.yml c:\ProjectFolder\Results");
Environment.Exit(1);
}

System.Console.Write(@"Metropolis v0.0.1 - Command Usage: metropolis.exe csharp");
Environment.Exit(0);
}
catch (Exception e)
Expand Down
45 changes: 45 additions & 0 deletions src/Metropolis.Cli.Console/NLog.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="false"
internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log">

<!-- optional, add some variables
https://github.com/nlog/NLog/wiki/Configuration-file#variables
-->
<variable name="myvar" value="myvalue"/>

<!--
See https://github.com/nlog/nlog/wiki/Configuration-file
for information on customizing logging rules and outputs.
-->
<targets>

<!--
add your targets here
See https://github.com/nlog/NLog/wiki/Targets for possible targets.
See https://github.com/nlog/NLog/wiki/Layout-Renderers for the possible layout renderers.
-->

<!--
Write events to a file with the date in the filename.
<target xsi:type="File" name="f" fileName="${basedir}/logs/${shortdate}.log"
layout="${longdate} ${uppercase:${level}} ${message}" />
-->

<target name="console" xsi:type="Console" />
</targets>

<rules>
<!-- add your logging rules here -->

<!--
Write all events with minimal level of Debug (So Debug, Info, Warn, Error and Fatal, but not Trace) to "f"
<logger name="*" minlevel="Debug" writeTo="f" />
-->

<logger name="*" minlevel="Trace" writeTo="console" />
</rules>
</nlog>