Browse Source

SONAR-14494 Adding the .NET Core tutorial in manual

tags/8.8.0.42792
Mathieu Suen 3 years ago
parent
commit
ff20a4b659

+ 21
- 60
server/sonar-web/src/main/js/components/tutorials/manual/commands/DotNet.tsx View File

@@ -18,11 +18,9 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import * as React from 'react';
import { FormattedMessage } from 'react-intl';
import { Link } from 'react-router';
import { translate } from 'sonar-ui-common/helpers/l10n';
import CodeSnippet from '../../../common/CodeSnippet';
import InstanceMessage from '../../../common/InstanceMessage';
import RenderOptions from '../../components/RenderOptions';
import DotNetCore from './DotNetCore';
import DotNetFramework from './DotNetFramework';

export interface DotNetProps {
host: string;
@@ -30,63 +28,26 @@ export interface DotNetProps {
token: string;
}

export default function DotNet(props: DotNetProps) {
const { host, projectKey, token } = props;

const command1 = [
'SonarScanner.MSBuild.exe begin',
`/k:"${projectKey}"`,
`/d:sonar.host.url="${host}"`,
`/d:sonar.login="${token}"`
];

const command2 = 'MsBuild.exe /t:Rebuild';
enum Variant {
DotNetCoreVariant = 'dotnet_core',
DotNetFrameworkVariant = 'dotnet_framework'
}

const command3 = ['SonarScanner.MSBuild.exe end', `/d:sonar.login="${token}"`];
export default function DotNet(props: DotNetProps) {
const [variant, setVariant] = React.useState<Variant>(Variant.DotNetCoreVariant);
const DotNetTuto = variant === 'dotnet_core' ? DotNetCore : DotNetFramework;

return (
<div>
<div>
<h4 className="spacer-bottom">{translate('onboarding.analysis.msbuild.header')}</h4>
<p className="spacer-bottom markdown">
<FormattedMessage
defaultMessage={translate('onboarding.analysis.msbuild.text')}
id="onboarding.analysis.msbuild.text"
values={{ code: <code>%PATH%</code> }}
/>
</p>
<p>
<Link
className="button"
to="/documentation/analysis/scan/sonarscanner-for-msbuild/"
target="_blank">
{translate('download_verb')}
</Link>
</p>
</div>

<h4 className="huge-spacer-top spacer-bottom">
{translate('onboarding.analysis.msbuild.execute')}
</h4>
<InstanceMessage message={translate('onboarding.analysis.msbuild.execute.text')}>
{transformedMessage => <p className="spacer-bottom markdown">{transformedMessage}</p>}
</InstanceMessage>
<CodeSnippet isOneLine={true} snippet={command1} />
<CodeSnippet isOneLine={true} snippet={command2} />
<CodeSnippet isOneLine={true} snippet={command3} />
<p className="big-spacer-top markdown">
<FormattedMessage
defaultMessage={translate('onboarding.analysis.docs')}
id="onboarding.analysis.docs"
values={{
link: (
<Link to="/documentation/analysis/scan/sonarscanner-for-msbuild/" target="_blank">
{translate('onboarding.analysis.msbuild.docs_link')}
</Link>
)
}}
/>
</p>
</div>
<>
<RenderOptions
checked={variant}
name="variant"
onCheck={value => setVariant(value as Variant)}
optionLabelKey="onboarding.build.dotnet.variant"
options={['dotnet_core', 'dotnet_framework']}
titleLabelKey="onboarding.build.dotnet.variant"
/>
<DotNetTuto {...props} />
</>
);
}

+ 52
- 0
server/sonar-web/src/main/js/components/tutorials/manual/commands/DotNetCore.tsx View File

@@ -0,0 +1,52 @@
/*
* SonarQube
* Copyright (C) 2009-2021 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

import * as React from 'react';
import { Alert } from 'sonar-ui-common/components/ui/Alert';
import { translate } from 'sonar-ui-common/helpers/l10n';
import CodeSnippet from '../../../common/CodeSnippet';
import { DotNetProps } from './DotNet';
import DotNetExecute from './DotNetExecute';

export default function DotNetCore(props: DotNetProps) {
const { host, projectKey, token } = props;

const commands = [
`dotnet sonarscanner begin /k:"${projectKey}" /d:sonar.host.url="${host}" /d:sonar.login="${token}"`,
'dotnet build',
`dotnet sonarscanner end /d:sonar.login="${token}"`
];

return (
<div>
<h4 className="huge-spacer-top spacer-bottom">
{translate('onboarding.analysis.dotnetcore.global')}
</h4>
<p className="big-spacer-top markdown">
{translate('onboarding.analysis.dotnetcore.global.text')}
</p>
<CodeSnippet snippet="dotnet tool install --global dotnet-sonarscanner" />
<Alert className="spacer-top" variant="info">
{translate('onboarding.analysis.dotnetcore.global.text.path')}
</Alert>
<DotNetExecute commands={commands} />
</div>
);
}

+ 60
- 0
server/sonar-web/src/main/js/components/tutorials/manual/commands/DotNetExecute.tsx View File

@@ -0,0 +1,60 @@
/*
* SonarQube
* Copyright (C) 2009-2021 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

import * as React from 'react';
import { FormattedMessage } from 'react-intl';
import { Link } from 'react-router';
import { translate } from 'sonar-ui-common/helpers/l10n';
import CodeSnippet from '../../../common/CodeSnippet';
import InstanceMessage from '../../../common/InstanceMessage';

export interface DotNetExecuteProps {
commands: string[];
}

export default function DotNetExecute({ commands }: DotNetExecuteProps) {
return (
<>
<h4 className="huge-spacer-top spacer-bottom">
{translate('onboarding.analysis.sq_scanner.execute')}
</h4>

<InstanceMessage message={translate('onboarding.analysis.msbuild.execute.text')}>
{transformedMessage => <p className="spacer-bottom markdown">{transformedMessage}</p>}
</InstanceMessage>
{commands.map((command, index) => (
<CodeSnippet key={index} snippet={command} />
))}
<p className="big-spacer-top markdown">
<FormattedMessage
defaultMessage={translate('onboarding.analysis.docs')}
id="onboarding.analysis.docs"
values={{
link: (
<Link to="/documentation/analysis/scan/sonarscanner-for-msbuild/" target="_blank">
{translate('onboarding.analysis.msbuild.docs_link')}
</Link>
)
}}
/>
</p>
</>
);
}

+ 62
- 0
server/sonar-web/src/main/js/components/tutorials/manual/commands/DotNetFramework.tsx View File

@@ -0,0 +1,62 @@
/*
* SonarQube
* Copyright (C) 2009-2021 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import * as React from 'react';
import { FormattedMessage } from 'react-intl';
import { Link } from 'react-router';
import { translate } from 'sonar-ui-common/helpers/l10n';
import { DotNetProps } from './DotNet';
import DotNetExecute from './DotNetExecute';

export default function DotNetFramework(props: DotNetProps) {
const { host, projectKey, token } = props;

const commands = [
`SonarScanner.MSBuild.exe begin /k:"${projectKey}" /d:sonar.host.url="${host}" /d:sonar.login="${token}"`,
'MsBuild.exe /t:Rebuild',
`SonarScanner.MSBuild.exe end /d:sonar.login="${token}"`
];

return (
<div>
<div>
<h4 className="spacer-bottom huge-spacer-top">
{translate('onboarding.analysis.msbuild.header')}
</h4>
<p className="spacer-bottom markdown">
<FormattedMessage
defaultMessage={translate('onboarding.analysis.msbuild.text')}
id="onboarding.analysis.msbuild.text"
values={{ code: <code>%PATH%</code> }}
/>
</p>
<p>
<Link
className="button"
to="/documentation/analysis/scan/sonarscanner-for-msbuild/"
target="_blank">
{translate('download_verb')}
</Link>
</p>
</div>

<DotNetExecute commands={commands} />
</div>
);
}

+ 1
- 1
server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/DotNet-test.tsx View File

@@ -21,6 +21,6 @@ import { shallow } from 'enzyme';
import * as React from 'react';
import DotNet from '../DotNet';

it('DotNet renders correctly', () => {
it('Should renders correctly', () => {
expect(shallow(<DotNet host="host" projectKey="projectKey" token="token" />)).toMatchSnapshot();
});

+ 26
- 0
server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/DotNetExecute-test.tsx View File

@@ -0,0 +1,26 @@
/*
* SonarQube
* Copyright (C) 2009-2021 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import { shallow } from 'enzyme';
import * as React from 'react';
import DotNetExecute from '../DotNetExecute';

it('Should renders correctly', () => {
expect(shallow(<DotNetExecute commands={['command1', 'command2']} />)).toMatchSnapshot();
});

+ 28
- 0
server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/DotNetFramework-test.tsx View File

@@ -0,0 +1,28 @@
/*
* SonarQube
* Copyright (C) 2009-2021 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import { shallow } from 'enzyme';
import * as React from 'react';
import DotNetFramework from '../DotNetFramework';

it('Should renders correctly', () => {
expect(
shallow(<DotNetFramework host="host" projectKey="projectKey" token="token" />)
).toMatchSnapshot();
});

+ 28
- 0
server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/DotnetCore-test.tsx View File

@@ -0,0 +1,28 @@
/*
* SonarQube
* Copyright (C) 2009-2021 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import { shallow } from 'enzyme';
import * as React from 'react';
import DotNetCore from '../DotNetCore';

it('Should renders correctly', () => {
expect(
shallow(<DotNetCore host="host" projectKey="projectKey" token="token" />)
).toMatchSnapshot();
});

+ 16
- 85
server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/__snapshots__/DotNet-test.tsx.snap View File

@@ -1,93 +1,24 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`DotNet renders correctly 1`] = `
<div>
<div>
<h4
className="spacer-bottom"
>
onboarding.analysis.msbuild.header
</h4>
<p
className="spacer-bottom markdown"
>
<FormattedMessage
defaultMessage="onboarding.analysis.msbuild.text"
id="onboarding.analysis.msbuild.text"
values={
Object {
"code": <code>
%PATH%
</code>,
}
}
/>
</p>
<p>
<Link
className="button"
onlyActiveOnIndex={false}
style={Object {}}
target="_blank"
to="/documentation/analysis/scan/sonarscanner-for-msbuild/"
>
download_verb
</Link>
</p>
</div>
<h4
className="huge-spacer-top spacer-bottom"
>
onboarding.analysis.msbuild.execute
</h4>
<InstanceMessage
message="onboarding.analysis.msbuild.execute.text"
>
<Component />
</InstanceMessage>
<CodeSnippet
isOneLine={true}
snippet={
exports[`Should renders correctly 1`] = `
<Fragment>
<RenderOptions
checked="dotnet_core"
name="variant"
onCheck={[Function]}
optionLabelKey="onboarding.build.dotnet.variant"
options={
Array [
"SonarScanner.MSBuild.exe begin",
"/k:\\"projectKey\\"",
"/d:sonar.host.url=\\"host\\"",
"/d:sonar.login=\\"token\\"",
"dotnet_core",
"dotnet_framework",
]
}
titleLabelKey="onboarding.build.dotnet.variant"
/>
<CodeSnippet
isOneLine={true}
snippet="MsBuild.exe /t:Rebuild"
<DotNetCore
host="host"
projectKey="projectKey"
token="token"
/>
<CodeSnippet
isOneLine={true}
snippet={
Array [
"SonarScanner.MSBuild.exe end",
"/d:sonar.login=\\"token\\"",
]
}
/>
<p
className="big-spacer-top markdown"
>
<FormattedMessage
defaultMessage="onboarding.analysis.docs"
id="onboarding.analysis.docs"
values={
Object {
"link": <Link
onlyActiveOnIndex={false}
style={Object {}}
target="_blank"
to="/documentation/analysis/scan/sonarscanner-for-msbuild/"
>
onboarding.analysis.msbuild.docs_link
</Link>,
}
}
/>
</p>
</div>
</Fragment>
`;

+ 44
- 0
server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/__snapshots__/DotNetExecute-test.tsx.snap View File

@@ -0,0 +1,44 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Should renders correctly 1`] = `
<Fragment>
<h4
className="huge-spacer-top spacer-bottom"
>
onboarding.analysis.sq_scanner.execute
</h4>
<InstanceMessage
message="onboarding.analysis.msbuild.execute.text"
>
<Component />
</InstanceMessage>
<CodeSnippet
key="0"
snippet="command1"
/>
<CodeSnippet
key="1"
snippet="command2"
/>
<p
className="big-spacer-top markdown"
>
<FormattedMessage
defaultMessage="onboarding.analysis.docs"
id="onboarding.analysis.docs"
values={
Object {
"link": <Link
onlyActiveOnIndex={false}
style={Object {}}
target="_blank"
to="/documentation/analysis/scan/sonarscanner-for-msbuild/"
>
onboarding.analysis.msbuild.docs_link
</Link>,
}
}
/>
</p>
</Fragment>
`;

+ 48
- 0
server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/__snapshots__/DotNetFramework-test.tsx.snap View File

@@ -0,0 +1,48 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Should renders correctly 1`] = `
<div>
<div>
<h4
className="spacer-bottom huge-spacer-top"
>
onboarding.analysis.msbuild.header
</h4>
<p
className="spacer-bottom markdown"
>
<FormattedMessage
defaultMessage="onboarding.analysis.msbuild.text"
id="onboarding.analysis.msbuild.text"
values={
Object {
"code": <code>
%PATH%
</code>,
}
}
/>
</p>
<p>
<Link
className="button"
onlyActiveOnIndex={false}
style={Object {}}
target="_blank"
to="/documentation/analysis/scan/sonarscanner-for-msbuild/"
>
download_verb
</Link>
</p>
</div>
<DotNetExecute
commands={
Array [
"SonarScanner.MSBuild.exe begin /k:\\"projectKey\\" /d:sonar.host.url=\\"host\\" /d:sonar.login=\\"token\\"",
"MsBuild.exe /t:Rebuild",
"SonarScanner.MSBuild.exe end /d:sonar.login=\\"token\\"",
]
}
/>
</div>
`;

+ 34
- 0
server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/__snapshots__/DotnetCore-test.tsx.snap View File

@@ -0,0 +1,34 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Should renders correctly 1`] = `
<div>
<h4
className="huge-spacer-top spacer-bottom"
>
onboarding.analysis.dotnetcore.global
</h4>
<p
className="big-spacer-top markdown"
>
onboarding.analysis.dotnetcore.global.text
</p>
<CodeSnippet
snippet="dotnet tool install --global dotnet-sonarscanner"
/>
<Alert
className="spacer-top"
variant="info"
>
onboarding.analysis.dotnetcore.global.text.path
</Alert>
<DotNetExecute
commands={
Array [
"dotnet sonarscanner begin /k:\\"projectKey\\" /d:sonar.host.url=\\"host\\" /d:sonar.login=\\"token\\"",
"dotnet build",
"dotnet sonarscanner end /d:sonar.login=\\"token\\"",
]
}
/>
</div>
`;

+ 10
- 2
sonar-core/src/main/resources/org/sonar/l10n/core.properties View File

@@ -3310,6 +3310,10 @@ onboarding.build.dotnet.linux_core=Linux + .NET Core
onboarding.build.cfamily=C,C++ or ObjC
onboarding.build.other=Other (for JS, TS, Go, Python, PHP, ...)

onboarding.build.dotnet.variant=Choose your build tool
onboarding.build.dotnet.variant.dotnet_core=.NET Core
onboarding.build.dotnet.variant.dotnet_framework=.NET Framework

onboarding.build.other.os=What is your OS?
onboarding.build.other.os.linux=Linux
onboarding.build.other.os.win=Windows
@@ -3348,9 +3352,9 @@ onboarding.analysis.java.gradle.text.2.sonarcloud=and add the following lines to

onboarding.analysis.msbuild.header=Download and unzip the Scanner for MSBuild
onboarding.analysis.msbuild.text=And add the executable's directory to the {code} environment variable
onboarding.analysis.msbuild.execute=Execute the Scanner for MSBuild from your computer
onboarding.analysis.msbuild.execute=Execute the Scanner for .NET from your computer
onboarding.analysis.msbuild.execute.text=Running a {instance} analysis is straighforward. You just need to execute the following commands at the root of your solution.
onboarding.analysis.msbuild.docs_link=official documentation of the Scanner for MSBuild
onboarding.analysis.msbuild.docs_link=official documentation of the Scanner for .NET
onboarding.analysis.msbuild.header.sonarcloud=Download and unzip the Scanner for MSBuild
onboarding.analysis.msbuild.text.sonarcloud=And add the executable's directory to the <code>%PATH%</code> environment variable
onboarding.analysis.msbuild.execute.sonarcloud=Execute the Scanner for MSBuild from your computer
@@ -3374,6 +3378,10 @@ onboarding.analysis.sq_scanner.docs_link=official documentation of the Scanner
onboarding.analysis.sqscanner.docs.gradle.title=official documentation of the Scanner for Gradle
onboarding.analysis.sqscanner.docs.gradle.example_project.title=live Gradle-based example project

onboarding.analysis.dotnetcore.global=Scanner .NET Core Global Tool
onboarding.analysis.dotnetcore.global.text=As a prerequisite you need to have the sonarscanner tool installed globally using the following command:
onboarding.analysis.dotnetcore.global.text.path=Make sure dotnet tools folder is in your path. See dotnet global tools documentation for more information.

onboarding.tutorial.return_to_list=Choose another option

onboarding.tutorial.choose_method=How do you want to analyze your repository?

Loading…
Cancel
Save